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?
(Google uses the World Geodetic System WGS84 standard.) World coordinates, which reference a point on the map uniquely.
First, open Google Maps on your computer, right-click the place you want to get coordinates. A pop-up window will show, you can find the latitude and longitude on the top. Left-click and copy them automatically.
Calculate latitude and longitude using the formula: latitude = asin (z/R) and longitude = atan2 (y,x). In this formula, we have the values of x, y, z and R from step 2. Asin is arc sin, which is a mathematical function, and atan2 is a variation of the arc tangent function. The symbol * stands for multiplication.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With