Tutorial :How do I convert these coordinates to coordinates readable by Google Maps?



Question:

Take a look at the map coordinates on this page. This is linked in from Wikipedia and the coordinates are passed the query string. I'm not sure of the actual terms for this but How do I convert the coordinates? They look like this:

37° 14′ 6″ N, 115° 48′ 40″ W

I would like them to look like this:

37.235, -115.811111

, which is a format readable by Google maps, as seen in this example.

How do I do this in PHP, and what are the two different types of coordinates called?


Solution:1

The original format is in hours, minutes, seconds format. To convert to decimal, do:

D = H + M/60 + s/3600

So in your example, 37,14,6 becomes

37 + 14/60 + 6/3600 = 37.235, as stated.

If the latitude is N the result is positive, if S, negative. If the longitude is E the result is positive. If west the result is negative.


Solution:2

Here is the Javascript function that does what you are talking about.

This utility permits the user to convert latitude and longitude between decimal degrees and degrees, minutes, and seconds. For convenience, a link is included to the National Geodetic Survey's NADCON program, which allows conversions between the NAD83 / WGS84 coordinate system and the older NAD27 coordinate system. NAD27 coordinates are presently used for broadcast authorizations and applications.

This utility requires that Javascript be enabled to perform the calculations.


Solution:3

Umm the page you mention already gives you the coordinates in WGS84 and in Latitude Longitude format


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »