Loading ...
Sorry, an error occurred while loading the content.

Custom Overlays

Expand Messages
  • Aubrey TF
    Hello! I am working on a map of classifieds on my site at safarri.com. I want people to be able to scroll around and have the ads automatically load in (i
    Message 1 of 1 , Sep 1, 2006
    View Source
    • 0 Attachment
      Hello!

      I am working on a map of classifieds on my site at safarri.com.
      I want people to be able to scroll around and have the ads
      automatically load in (i believe this is called an overlay).
      I wrote the below simple code to load ads in a special format served
      by my server, but the problem is that it loads all the ads at once. We
      need to make it tile! I believe the function needs to be attached to
      the onmapmove event (or whatever its called), and it needs to be able
      to figure out what latlon boxes are in "view" and request them from
      the server.

      -Aubrey



      <div id="map" style="height:500px;"></div>


      <script type="text/javascript">
      var map = new Map("map");
      map.addEventListener(Map.EVENT_INITIALIZE, mapInit);
      //map.drawZoomAndCenter(new LatLon (48.055621, -116.585400), 5);

      function mapInit() {
      map.addTool( new PanTool(), true );
      map.addWidget( new NavigatorWidget() );
      map.addWidget(new SatelliteControlWidget());
      loadMarkers();
      }

      function loadMarkers(result) {
      xmlhttp = new XMLHttpRequest();
      xmlhttp.open('GET', '/browse-tpl-map' , true);
      xmlhttp.onreadystatechange = function() {
      if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      var markers=xmlhttp.responseText.split('\r\n');
      for (i in markers) {
      var marker=markers[i].split(';');
      map.addMarkerByAddress( new CustomPOIMarker( marker[6] + " -- "
      , "", "<a href=\"/ad-id-" + marker[0] + "\"><img align=\"left\"
      src=\"" + marker[7] + "\" \></a><br />" + marker[3] + ": " + marker[4]
      + " " + marker[5] + "<br />" + marker[1] + "<br />" + marker[2] + "<br
      /><br /><a href=\"/ad-id-" + marker[0] + "\">>> View Ad</a><br />",
      '0xFF0000', '0xFFFFFF'), marker[1]);
      }
      }
      };
      xmlhttp.send(null);
      }
      </script>
    Your message has been successfully submitted and would be delivered to recipients shortly.