jawj / OverlappingMarkerSpiderfier-Leaflet

Deals with overlapping markers in the Leaflet maps API, Google Earth-style
253 stars 68 forks source link

circleMarker click not getting called #19

Open iamtennislover opened 9 years ago

iamtennislover commented 9 years ago

Hi, I see that the click event doesn't get called for circleMarker, but does get called for normal Marker. Any help?

http://jsfiddle.net/abarik/crk3jrhp/2/

html

<div id="map"></div>

css

#map {
    height: 440px;
}

javascript

map = L.map('map', {
    center: [7.2, 40.9],
    zoom: 2
});

L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
    attribution: "Map: Tiles Courtesy of MapQuest (OpenStreetMap, CC-BY-SA)",
    subdomains: ["otile1", "otile2", "otile3", "otile4"],
    maxZoom: 12,
    minZoom: 2
}).addTo(map);

var oms = new OverlappingMarkerSpiderfier(map);
var popup = new L.Popup();
oms.addListener('click', function(marker) {
  popup.setContent(marker.__name);
  popup.setLatLng(marker.getLatLng());
  map.openPopup(popup);
});

var marker1 = new L.Marker([1, 1]);
marker1.__name = 'marker1'
map.addLayer(marker1);
oms.addMarker(marker1);

var marker2 = new L.Marker([1, 1]);
marker2.__name = 'marker2'
map.addLayer(marker2);
oms.addMarker(marker2);

var marker1 = new L.circleMarker([20, 20]);
marker1.__name = 'cirmarker1'
map.addLayer(marker1);
oms.addMarker(marker1);

var marker2 = new L.circleMarker([20, 20]);
marker2.__name = 'cirmarker2'
map.addLayer(marker2);
oms.addMarker(marker2);