More advanced stuff

Google Maps API Tutorial

Using pseudo-HTML data files for maxContent

If you’re using maxContent, or anything else, to display large quantities of HTML data about each marker, then you’ve got to store that data somewhere. If you’ve got lots of markers, things can get messy.

You could store the data in one large XML file or plain text file, but that becomes a pain to create and maintain if you’ve got large amounts of HTML data for each marker.

You could store the maxContent for each marker in a separate HTML file, which you load on demand. The only problem with that is that if you’ve got lots of markers, you end up with lots of files. If you’re using something like googlepages, you have to upload each file, one by one, and there’s a limit of 500 files per googlepages site.

What I came up with is storing the data in one rather unconventional HTML file. The file contains the maxContent HTML for all the markers, using <hr> as a separator. It doesn’t have <head>, <body> or <html> tags or a Doctype, because the maxContent gets injected into a div.innerHTML within an existing page. However, it’s still close enough to acceptable HTML for you to be able to load it into a browser and check the format and content of all the sections at once.

I’ve also put other data about the markers in the same file, separated with “|” characters, but you could just as well store the other data in a separate XML file with the records arranged in the same order.

The data is read in a similar manner to that used when reading a plain text data file, except that the data is split into sections using “<hr>” as the separator, rather than “\n”.

Advertisements