Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 279
Ali Avatar asked Jun 15 '09 12:06

Ali


People also ask

What type of coordinates does Google Maps use?

(Google uses the World Geodetic System WGS84 standard.) World coordinates, which reference a point on the map uniquely.

How do I extract coordinates?

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.

How do you convert XY coordinates to latitude and longitude?

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.


1 Answers

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.

like image 54
PaulJWilliams Avatar answered Sep 19 '22 13:09

PaulJWilliams