back | source
Create Overlays
  1. Create longdo.Marker object
    var marker1 = new longdo.Marker({ lon: 99, lat: 13 });
    
    var marker2 = new longdo.Marker({ lon: 101.2, lat: 12.8 },
    {
      title: 'Marker',
      icon: { url: 'https://map.longdo.com/mmmap/images/pin_mark.png', offset: { x: 12, y: 45 } },
      detail: 'Drag me',
      visibleRange: { min: 7, max: 9 },
      draggable: true,
      weight: longdo.OverlayWeight.Top
    });
    
    var marker3 = new longdo.Marker({ lon: 101, lat: 12 },
    {
      title: 'Custom marker',
      icon: { html: '<em>icon</em>', offset: { x: 18, y: 21 } },
      popup: {
        html: '<div style="background: #eeeeff;">popup</div>'
      }
    });
    
    var marker4 = new longdo.Marker({ lon: 100.41, lat: 13.84 },
    {
      rotate:90
    });
    • lon,lat: latitude and longitude
    • title: message that will appear on the header of the popup
    • detail: message that will appear on the detail of the popup
    • icon: pictures displayed on the map
    • url: link of an image file that will be an overlay
    • visibleRange: visible range
    • draggable: the overlay can be dragged
    • weight: weight, for add marker to top
    • html: customize html for overlays
        * Have performance impact if add a lot of marker
    • offset: icon offset
    • popup: customize popup
    • rotate: marker rotation in degree, relative to nort (0-360)
    Example

  2. More information: Marker Documentation

  3. Create longdo.Popup object
    var popup1 = new longdo.Popup({ lon: 99, lat: 14 },
    {
      title: 'Popup',
      detail: 'Simple popup'
    });
    
    var popup2 = new longdo.Popup({ lon: 101, lat: 14 },
    {
      title: 'Popup',
      detail: 'Popup detail...',
      loadDetail: updateDetail,
      size: { width: 200, height: 200 },
      closable: false
    });
    var popup3 = new longdo.Popup({ lon: 102, lat: 14 },
    {
      html: '<div style="background: #eeeeff;">popup</div>',
    });
    
    function updateDetail(element) {
      setTimeout(function() {
        element.innerHTML = 'Content changed';
      }, 1000);
    }
    • lon,lat: latitude and longitude
    • title: message that will appear on the header of the popup
    • detail: message that will appear on the detail of the popup
    • size: size of popup
    Example

  4. More information: Popup Documentation

  5. Add overlay
    map.Overlays.add(marker1);
  6. Remove overlay
    // Remove Marker
    map.Overlays.remove(marker1);
    
    // Remove Popup
    map.Overlays.remove(popup1);
    Example
  7. Clear all overlay
    map.Overlays.clear();
    Example