/ Published in: jQuery
Nice ajax function to grab the latitude and longitude of an address or postcode. Don't forget your google key and address formatting.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script> jQuery(document).ready(function(){ var jsapiKey = "YOUR API KEY"; var address = "YOUR+ADDRESS"; jQuery.getJSON("http://maps.google.com/maps/geo?q="+address+"&key="+jsapiKey+"&sensor=true&output=json&callback=?", function(data, textStatus){ console.log("Latitude: "+data.Placemark[0].Point.coordinates[1]); console.log("Longitude: "+data.Placemark[0].Point.coordinates[0]); }); }); </script>