tabris-plugin-maps icon indicating copy to clipboard operation
tabris-plugin-maps copied to clipboard

Provide convenience API for removing all markers

Open cpetrov opened this issue 8 years ago • 0 comments

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.

cpetrov avatar Jan 20 '17 16:01 cpetrov