Categories
Google Google Maps MySql PHP phpMyAdmin Programming Languages

How to store Longitude/Latitude, from Google Maps in MySql?

If you are confused about the field type of longitude/latitude in the database tables and you are thinking about decimal or float then use the best way defined below.

In MySQL or SQL Server, we can save it as FLOAT( 10, 6 ) NOT NULL

This is the recommendation from google itself: https://developers.google.com/maps/articles/phpsqlajax

CREATE TABLE `markers` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 60 ) NOT NULL ,
`address` VARCHAR( 80 ) NOT NULL ,
`lat` FLOAT( 10, 6 ) NOT NULL ,
`lng` FLOAT( 10, 6 ) NOT NULL ,
`type` VARCHAR( 30 ) NOT NULL
) ENGINE = MYISAM ;

If you are using phpmyadmin then you can save the latitude and longitude shown below.