Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

162 Part III — Google Map Hacks


Listing 9-10: Adjusting the JavaScript to Create an Information Window

function addmarker(x,y,title) {
var point = new GPoint(parseFloat(x),parseFloat(y));
points.push(point);
var marker = new GMarker(point);
GEvent.addListener(marker,
‘click’,
function() {
marker.openInfoWindowHtml(‘<b>’ + title + ‘</b>’);
}
);
map.addOverlay(marker);
infopanel.innerHTML = infopanel.innerHTML +
‘<a href=”#” onClick=”movemap(‘ + index + ‘);”>’ +
title +
‘</a><br/>’;
index++;
}

The limitation of the preceding solution is that you have to format the HTML that is contained
within the panel by hand, although as you can see from Figure 9-3, the result is quite effective.

FIGURE9-3: A basic information window.
Free download pdf