topical media & game development

talk show tell print

mashup-flickr-13-Step-6-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() 
      {
             marker.openInfoWindowHtml("<p>Photo Id: " + id + "</p>");
      });
          
      return marker;
  }
  
  


(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.