topical media & game development
mashup-flickr-13-Step-7-lib-js-map.js / js
function doMap()
{
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(0, 0), 1);
GDownloadUrl(<geo.php>, function(data, responseCode)
{
var xml = GXml.parse(data);
var photos = xml.documentElement.getElementsByTagName("photo");
for (var i = 0; i < photos.length; i++)
{
var id = photos[i].getAttribute("id");
var latitude = parseFloat(photos[i].getAttribute("latitude"));
var longitude = parseFloat(photos[i].getAttribute("longitude"));
var point = new GLatLng(latitude, longitude);
var marker = createMarker(point, id);
map.addOverlay(marker);
}
});
}
function createMarker(point, id)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function()
{
displayMarkerInfo(marker, id);
});
return marker;
}
function displayMarkerInfo(marker, id)
{
GDownloadUrl("geoview.php?id=" + id, function(data, responseCode)
{
marker.openInfoWindowHtml(data);
});
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.