Closed jochenjonc closed 6 years ago
I don't know the boxzoomend event, yet. Can you provide a link to the according documentation or source-code?
Wel it's something I found on StackOverflow, but I can't find it in the leaflet API. https://stackoverflow.com/questions/17611596/multiple-marker-selection-within-a-box-in-leaflet
I can get it working via the following code:
// Select multiple trucks
const that = this;
this.mapComponent.on('boxzoomend', function(event: any) {
this.lastTrucksSelected = new Array();
that.truckGroup.eachLayer(function (layer) {
if (layer instanceof L.Marker) {
if (event.boxZoomBounds.contains(layer.getLatLng())) {
const truckMarker = layer as any;
that.lastTrucksSelected.push(truckMarker.options.truckId);
}
}
});
});
It seems that there is a BoxZoom handler, but it is not part of the documentation. We can add this event-handler to leaflet-ng2, also.
Is there a 'nice' way to subscribe to the boxzoomend event? Or is
map.on("boxzoomend", function(e) { ... }
the only solution?The purpose it to list all markers that are in the zoombox bounds.