Converting longitude/latitude to X/Y coordinate

The big issue with plotting maps is that the spherical surface of the Earth cannot be conveniently converted into a flat representation. There are a bunch of different projections that attempt to resolve this. Mercator is one of the simplest: it assumes that lines of equal latitude are parallel horizontals, while lines of equal longitude …

Read more

Get latitude and longitude based on location name with Google Autocomplete API

You can use the Google Geocoder service in the Google Maps API to convert from your location name to a latitude and longitude. So you need some code like: var geocoder = new google.maps.Geocoder(); var address = document.getElementById(“address”).value; geocoder.geocode( { ‘address’: address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { // do something with the …

Read more

Maximum Lat and Long bounds for the world – Google Maps API LatLngBounds()

The links provided by @Marcelo & @Doc are good for understanding the derivation of the Lat Lng: http://www.cienciaviva.pt/latlong/anterior/gps.asp?accao=changelang&lang=en https://groups.google.com/forum/?hl=en&fromgroups=#!msg/google-maps-api/oJkyualxzyY/pNv1SE7qpBoJ https://en.wikipedia.org/wiki/Mercator_projection#Mathematics_of_the_Mercator_projection But if you just want an answer for the maximum bounds for Google Maps: Latitude: -85 to +85 (actually -85.05115 for some reason) Longitude: -180 to +180 Try it for yourself on the Google Maps: …

Read more

Retrieve latitude and longitude of a draggable pin via Google Maps API V3

Either of these work google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = event.latLng.lat(); document.getElementById(“lngbox”).value = event.latLng.lng(); }); google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); }); You might also consider using the dragend event also google.maps.event.addListener(marker, ‘dragend’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); });