Skip to content

Instantly share code, notes, and snippets.

@lordspace
Created February 14, 2014 22:14
Show Gist options
  • Save lordspace/9010525 to your computer and use it in GitHub Desktop.
Save lordspace/9010525 to your computer and use it in GitHub Desktop.
Convert a string Lat/Long to Google Maps API LatLng Object
// This function accepts lat latitude from a string
// e.g. 123,-234
function getLatLngFromString(ll) {
var lat = ll.replace(/\s*\,.*/, ''); // first 123
var lng = ll.replace(/.*,\s*/, ''); // second ,456
var latLng = new google.maps.LatLng(parseFloat(lat), parseFloat(lng));
return latLng;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment