I’m trying to use google maps’ REST api to convert an typed in adress to coordinates. To do so I use jQuery’s getJSON function as it uses a native JSONP call.
Though it won’t work, it just doesn’t get to success, so the alert is never called.
$("#makeCords").click(function(){
straat = $('#straat').val();
stad = $('#Stad').val();
land = $('#Country').val();
if(straat == "" || stad == "" || land == ""){
alert("Onvoldoende gegevens! Vul straat, stad en land aan voor het gebruik van de ´bereken coordinaten´ functie.");
}else{
$.getJSON("http://maps.google.com/maps/api/geocode/json?callback=?",
{
adress: straat +", " + stad +", " + land,
sensor: "false"
},
function(data) {
alert(data);
});
}
});
The Google Maps Geocoding API does not support JSON-P; it will ignore your
callbackparameter, thus cross-domain JSON-P won’t work.You should use official Google Maps Javascript library instead. Internally the library does use JSON-P to pass the information (since it’s almost the only way to do cross-domain requests), but that URL is reserved to official library use only.