1

I have a form where I can enter the coordinates of a location in the DMS format which gets stored in a table. I find the coordinates by dragging the marker to the place I need, using http://itouchmap.com/latlong.html

The degree, minutes and seconds are separated by white spaces rather than the usual symbols.

Example:

  • Lat : 9 59 35.9274
  • Lng : 76 17 49.0524

These values are being stored in fields which are of varchar and are stored as it is.

Could someone tell me what the problem is?

But when I retrieve these coordinates to plot it on Google maps, the marker is in some place else.

P.S. : The marker placing works perfect when the coordinates are stored in the DDD format.

The code I use is copy pasted from https://developers.google.com/maps/articles/phpsqlajax_v3?csw=1

Anagh
  • 373
  • 1
  • 5
  • 15
  • If I understand you properly than you have to change latlng from DMS format do Decimal Degrees Latitude/Longitude values. – Anto Jurković Dec 20 '13 at 11:27
  • 1
    I was initially using float(10,6). But the GPS device I use is giving me the coordinates in the DMS format. Please google **40 42 51, -74 0 22**. You can see that the marker is being placed on the map, which I think means we have the option to enter them in the DMS format too, not just the DDD format. Thanks... – Anagh Dec 20 '13 at 11:39

1 Answers1

3

The article stipulates that the long and late should be stored as type decimal(10,6) to allow for four digits before and six after the decimal. The maps api will not reliably accept these coordinates in any other format.

You would have to handle conversion from degrees minutes seconds to decimal before storing into the table and then reading out to your map.

Suggested reading: how to convert between degrees, minutes, seconds to Decimal coordinates

http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

Regex/Javascript to transform Degrees Decimal Minutes to Decimal Degrees

Edit See link here. Google maps API does not support DMS unless implemented in a very specific way (in which case you're formatting the string yourself and could simply convert? Your choice.

The issue is that the API expects the longitude and latitude as an integer and therefore spaces are not accepted.

Converstion to decimal would be as simple as this if I'm correct (in javascript):

var = hour+(((minute*60)+(second))/3600);
Community
  • 1
  • 1
ChrisSwires
  • 2,713
  • 1
  • 15
  • 28
  • I was initially using float(10,6). But the GPS device I use is giving me the coordinates in the DMS format. Please google **40 42 51, -74 0 22**. You can see that the marker is being placed on the map, which I think means we have the option to enter them in the DMS format too, not just the DDD format. Thanks... – Anagh Dec 20 '13 at 11:38