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. | |