tabris-plugin-maps
tabris-plugin-maps copied to clipboard
Provide convenience API for removing all markers
Currently, marker.dispose()
removes the marker from the map.getMarkers()
array. Something like:
map.getMarkers().forEach(marker => marker.dispose());
... would not work, since the array would be modified by marker.dispose()
. In this case one needs to use a reverse for loop, which is not very convenient:
let markers = map.getMarkers();
for (let i = markers.length - 1; i >= 0; i--) {
markers[i].dispose();
}
I suggest offering a type for the markers collection similar to WidgetCollection
, which allows disposing (e.g. map.getMarkers().dispose()
) and configuring all markers at once.