back | source
Displaying multiple location
  1. Multiple locations can be shown by adding multiple markers
    map.Tags.add(function(tile, zoom) {
      var bound = longdo.Util.boundOfTile(map.projection(), tile);
      mockAjaxFromServer(bound, function(locationList) {
        for (var i = 0; i < locationList.length; ++i) {
          map.Overlays.add(new longdo.Marker(locationList[i], { visibleRange: { min: zoom, max: zoom } }));
        }
      });
    });
  2. Randomized location
    function mockAjaxFromServer(bound, callback) {
      var locationList = [];
      var count = Math.random() * 5;
      for (var i = 0; i < 3; ++i) {
        locationList.push({ lon: bound.minLon + (Math.random() * (bound.maxLon - bound.minLon)),
          lat: bound.minLat + (Math.random() * (bound.maxLat - bound.minLat)) });
      }
      callback(locationList);
    }