Last active
February 12, 2022 22:50
-
-
Save rufuspollock/4994760 to your computer and use it in GitHub Desktop.
This file contains hidden or 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); | |
}); |
@ttresslar i've fixed the bracket. I suspect this no longer runs as mapquestapi no longer supports that url ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, I'm having an issue running this code. FIrst, on line 10, there is an extra bracket, so that gives me a syntax error. But even without the bracket, I can't get it to run. Any suggestions?