Skip to content

Instantly share code, notes, and snippets.

@jefsnare
Created September 16, 2014 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefsnare/3c6ac2263045bf02602f to your computer and use it in GitHub Desktop.
Save jefsnare/3c6ac2263045bf02602f to your computer and use it in GitHub Desktop.
Convert Google Maps API LatLng object to string/array
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': '1071 CX, Amsterdam, NL' }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var result = results[0],
latlng = result.geometry.location.toString().replace(/\(|\)/g, '').split(', '));
console.log(latlng[0]); //lat
console.log(latlng[1]); //long
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment