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

0

Posted on : 26-03-2012 | By : | In : Google, Google Maps, MySql, PHP, phpMyAdmin, Programming Languages

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.
programming languages phpmyadmin php mysql google maps google  phpsqlgeocode createtable

Tags:

If you liked this post you may want to Subscribe to Latest CodeMasterz buzz about Tech Tips, Worpdress Tips and more updates in your inbox.

Enter your email address:     Delivered by FeedBurner

Post a comment