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 in this post.

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.

By Vaseem Ansari

Hey guys this is Vaseem Ansari, 27 years old, Software & Web Developer, Blogger & works on Wordpress Plugin Themes Development, PHP MySql Programming and Open Sources Technologies.
It takes a while for me to build trust in someone new. I am honest, thoughtful. I'm Glad I'm Me No one looks The way I do. No one walks the way I walk. No one talks the way I talk. I am me. There's no one else I'd rather be! Have fun reading this blog and don't forget to subscribe to the feed to keep updated on the latest articles.

Leave a Reply

Your email address will not be published. Required fields are marked *