Forked from rufuspollock/geocode-with-nominatim-and-jquery.js
Created
January 30, 2014 06:37
-
-
Save pierrelorioux/8703685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the location we want to GeoCode | |
var location = 'London'; | |
// we are using MapQuest's Nominatim service | |
var geocode = 'http://open.mapquestapi.com/search?format=json&q=' + location; | |
// use jQuery to call the API and get the JSON results | |
$.getJSON(geocode, function(data) { | |
// get lat + lon from first match | |
var latlng = [data[0].lat, data[0].lon]] | |
console.log(latlng); | |
// let's stringify it | |
var latlngAsString = latlng.join(','); | |
console.log(latlngAsString); | |
// the full results JSON | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment