Monday, 24 March 2008

Google Maps on the fly

Adding Google Maps and dynamically filling it with goodies you have stored in a database is an exciting thing, but there are a number of alternatives available to you when deciding to do this. Firstly, GDownloadUrl(url) Can be used to go off and get a remote file for you. This remote file can be an XML file and parsed using the GXml() although this then leads to navigating the DOM to extract the data you want. Secondly, if the XML file your downloading is more specifically a KML file (very possible considering you may be producing that file from your database). You may want to just use the GGeoXML() class. This class can be passed a KML directly and theoretically get displayed on a map using map.addOverlay(GGeoXML). However, this doesn't give you access to a function you may have to create (and therefore return) a marker. This function is useful because it allows stuff to be bound to particular marker instances (like code for click events). With GGeoXML you loose this.

I keep seeming to start by plotting an arbiturary XML file full of <marker> tags. I then decide to use a standard XML file like KML, get satisfied, then remember the GGeoXML which could have done most of it for me.

No comments: