$(function() {
var apiKey = "YOUR-API-KEY-HERE";
var ip = "1.2.3.4";// Specify the IP you want to geocode
ip = "detect";// Or specify the IP as 'detect' to use the IP address of the client that is placing the API call
var url = "https://api.geolake.com/geocode?api_key=" + encodeURIComponent(apiKey) +
"&ip=" + encodeURIComponent(ip);
$.get(url, function(data) {
if(data.success) {
var countryCode;
var currencyCode;
var timezone;
var city;
if(data.place) {
countryCode = data.place.countryCode;
currencyCode = data.place.currencyCode;
timezone = data.place.timezone;
city = data.place.city;
}
//NOTE: Depending on the IP address, some of the returned values might be undefined
console.log("Coordinate: " + data.latitude + "; " + data.longitude);
console.log("City: " + city + ", " + countryCode);
console.log("Currency: " + currencyCode);
console.log("Timezone: " + timezone);
} else {
console.log("Could not find the specified IP address");
}
});
});