I’m trying to use the Google Geocoder API to get me a Latitude and Longitude to use in the Google Places API. First things first, how do I code the url of the API so it returns the JSON string? I thought it would be something like a jquery load, but that doesn’t work. So I have this nice url that returns the information I need but just dumps a bunch of json data. How do I capture the data?
http://maps.googleapis.com/maps/api/geocode/address=12308&sensor=false
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/geocode/address=12308&sensor=false";
document.body.appendChild(script);
resultjson = script
console.log(resultjson);
}
You can use the geocoder without the JSONP support but you have to use their Maps library instead:
Add this script tag to your HTML:
Then, add the following JS: