Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps API maximal coordinate length?

This may sound weird, but i need to know what the maximum amount of digits in a coordinate in the Google maps API is.

Say for an example, i use their "Web Services" API to find an address, then what is the longest possible lat/lng number? like xxx.xxxxx...

I see them referring to a 10 digit number (not counting the dot) in their documentation for the web services api, but i don't know if that's the max?..
Personally i haven't seen anything more than 7 digits after the dot returned, but i know google can at least search for a seemingly endless coordinate.

If anyone knows for sure what the longest coordinate you can expect returned is, please let me know.

like image 821
Kristoffer la Cour Avatar asked Aug 01 '26 22:08

Kristoffer la Cour


1 Answers

SQL-wise:

Latitude/Longitude should use FLOAT/DOUBLE precision.

It's definitely not recommend to use e.g. VARCHAR(20) because numeric comparisons would fail for sure.

API-wise:

Same applies for the Maps JS API; about the various Data-APIs I'm not sure (and have no time to test that)

(probably just precision-reduction/proximity...)

PHP Manual - Floating point numbers:

The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value (the 64 bit IEEE format).

update just being down-voted (5 years later) without a reason (most likely by someone, who failed to comprehend)... while newer versions of mySQL even feature a Point datatype, in order to represent coordinates... still API wise, the data is always posted as String.

like image 68
Martin Zeitler Avatar answered Aug 04 '26 10:08

Martin Zeitler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!