I have GPS information presented in the form:
36°57'9" N 110°4'21" W
I can use the javascript functions of Chris Veness to convert degrees, minutes and seconds to numeric degrees, but first need to parse the GPS info into the individual latitude and longitude strings (with NSEW suffixes). I have read related posts on stackoverflow, but am not a regex expert (nor a programmer) and need some help with the parsing function. What's the best way to parse this string into latitude and longitude for use in the conversion function?
The result of all this will be a Web link that one can click on to see a Google map representation of location.
My tweaked version coerces the string parts into Numbers so that they can actually be added together rather than concatenated. It also handles decimal values which are common for the Seconds component:
The following will convert your DMS to DD
here is my take on this:
}
This function doesn't handle all types of lat / long types, but it handles the following formats:
Which is what i needed.
Corrected the above functions and made the output an object.
I used \d+(\,\d+) and \d+(.\d+) because can have float numbers
My final function:
To parse your input use the following.
The following will convert your DMS to DD
So your input would produce the following:
Decimal coordinates can be fed into google maps to get points via
GLatLng(lat, lng)
(Google Maps API)Joe, the script you've mentioned already did what do you want. With it you can convert lat and long and put it into link to see location in Google map: