Created
February 14, 2014 22:14
-
-
Save lordspace/9010525 to your computer and use it in GitHub Desktop.
Convert a string Lat/Long to Google Maps API LatLng Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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