-
Google Mashups, pt. 3
Posted on April 24th, 2009 No commentsThis time around, I want to figure out to load data from an XML file and how that XML file should be structured. Having never worked with XML files from scratch before, I’m a little apprehensive, but, hey, there’s not much that can actually break…
First, I set up my map controls:
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());Problem is, I don’t dig the tiny controls (hello, 2001 called…), so I updated to the latest version I can find in the API docs:
map.addControl(new GLargeMapControl3D());
map.addControl(new GMapTypeControl());This version of the map is here.
Ok, so here’s an interesting thing. The new control I’m using still doens’t match the current control on maps.google.com. I’m not sure why, but I’m sure it has something to do with StreetView, and I probably need to learn how to use the specialized StreetView tools…but I digress.
Oh, bonus! Looks like the tutorial I’m using has _blank">section on working with an XML file…tells me to use the GDownloadURL method:
GDownloadUrl("data.xml", function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
map.addOverlay(new GMarker(point));Problem is, it doesn’t work, and although I spend some time peering at it, I’m just not quite yet comfortable enough to spot whatever’s broken. The tutorial is from 2006…I guess the API could have changed. More googling is in order.
Leave a reply


