I am trying to get the lng and lat coordinates of the Google Maps API in the following http://jsbin.com/inepo3/7/edit example. I expect a success popup, but it continues to show an Error popup. Google maps-request gives correct json feedback (checked by firebug).
<script type="text/javascript"> $().ready(function() { $.fn.getCoordinates=function(address){ $.ajax( { type : "GET", url: "http://maps.google.com/maps/api/geocode/json", dataType: "jsonp", data: { address: address, sensor: "true" }, success: function(data) { set = data; alert(set); }, error : function() { alert("Error."); } }); }; $().getCoordinates("Amsterdam, Netherlands"); }); </script>
Does anyone know how to fix this problem?
Regards, Guido Lemmens
EDIT
I found a solution using the Google Maps Javascript API integrated in jQuery:
<script type="text/javascript"> $().ready(function() { var user1Location = "Amsterdam, Netherlands"; var geocoder = new google.maps.Geocoder(); </script>
Guido Lemmens 2
source share