Return to Snippet

Revision: 55135
at January 27, 2012 21:41 by Blerx


Initial Code
<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>

Initial URL

                                

Initial Description
Nice ajax function to grab the latitude and longitude of an address or postcode. Don't forget your google key and address formatting.

Initial Title
Get Latitude and Longitude using jQuery and Googles Geo Coding Service

Initial Tags

                                

Initial Language
jQuery