Here's a quick MySQL-Googlemaps how to.


Start with a very basic map. Then, make the call to retrieve the marks from a database. The database is accessed via a php script. The PHP script's sole purpose in life is to retrieve the data. The data is returned to the script in XML format.
The marks are stored in a MySQL database. There are 4 fields in this table, 1 for the index, 1 for the name, and 1 each for latitude and longitude. The data returned looks like this: data
A sample php script can be found here. You need to add
<?php
as the first line, and
?>
as the very last line. Rename it to marks.php
The marks get displayed starting with the javascript function call:
getMarks("marks.php?name=one");
Here's the javascript that retreives the marks. Opens in new window, narrative continues here.
The createMarker function is the standard function taken from other tutorials
The getMarks function gets called from index.php passing the 'url' with any limiters for the database query
In my example, I pass 'name=one'. All 'one' does is to determine which query to use. in this case, just query the db and return 10 entries. 'two' would return 20 entries.
These are the basics. If you want, you can add a sidebar to list the marks on the side. If you want to limit the marks, you could also take the bounds of the current map, and pass those to the PHP script. Let PHP return results within those bounds.
Here are the files to get the basics up and running:
Check the files, some things need to be changed
html file basic HTML that will generate the map.
maps.js the javascript functions. Save as maps.js
php file Save as marks.php (called from maps.js) You should be able to alter the server settings at the top, then call this page and not get an error. You also need to add <?php as the first line, and ?> as the very last line
mysqldump can be used to load a sample table called "tutor". 'marks.php' above uses this data and structure.



Feel free to link to this page whereever you like.

Feel free to email me with questions, comments or any gripes you have about this page. roger.in.eugene@gmail.com


Tutorial for altering markers based on dates
How to limit the query based on the current view
Here's a page for help inserting images into a MySQL database.

Page that grabs quake data from a database then displays earthquakes that have happened recently

Web hosting