jawj / OverlappingMarkerSpiderfier-Leaflet

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

out of need #30

Open robertleeplummerjr opened 8 years ago

robertleeplummerjr commented 8 years ago

Thank you for this fine library. I did some cleanup and modernization to it in hopes that it would help me and thought I'd offer it if needed.

Thanks again.

robertleeplummerjr commented 8 years ago

I went ahead and created a full fledged control that should make reuse pretty easy and simplified some of the terminology. You can now do this with this branch:

L.spiderfy({
  map: map,
  markers: markers,
  click: function(marker) {
    popup.setContent(marker.desc);
    popup.setLatLng(marker.getLatLng());
    map.openPopup(popup);
  },
  activate: function(markers) {
    markers.forEach(function(marker) {
      marker.setIcon(new LightIcon());
    });
    map.closePopup();
  },
  deactivate: function(markers) {
    markers.forEach(function(marker) {
      marker.setIcon(new DarkIcon());
    });
  }
});
OrbitalStudios commented 8 years ago

I don't trust it.

robertleeplummerjr commented 8 years ago

What?