class MarkerManager

This class is used to manage visibility of hundreds of markers on a map, based on the map's current viewport and zoom level.

Constructor

Constructor Description
MarkerManager(map, opts?) Creates a new marker manager that controlls visibility of markers for the specified map.

Methods

Methods Return Value Description
addMarkers(markers, minZoom, maxZoom?) none Adds a batch of markers to this marker manager. The markers are not added to the map, until the refresh() method is called. Once placed on a map, the markers are shown if they fall within the map's current viewport and the map's zoom level is greater than or equal to the specified minZoom. If the maxZoom was given, the markers are automatically removed if the map's zoom is greater than the one specified.
addMarker(marker, minZoom, maxZoom?) none Adds a single marker to a collection of markers controlled by this manager. If the marker's location falls within the map's current viewport and the map's zoom level is within the specified zoom level rage, the marker is immediately added to the map. Similar to the addMarkers method, the minZoom and the optional maxZoom parameters specify the range of zoom levels at which the marker is shown.
removeMarker(marker) none Removes marker from the MarkerManager by searching at every zoom level to find grid cell that marker would be in, removing from that array if found. Also calls removeOverlay on marker if currently visible.
clearMarkers() none Removes all currently displayed markers and clears grid arrays.
refresh() none Forces the manager to update markers shown on the map. This method must be called if markers were added using the addMarkers method.
getMarkerCount(zoom) Number Returns the total number of markers potentially visible at the given zoom level. This may include markers at lower zoom levels.

Events

Events Arguments Description
changed bounds, markerCount This event is fired when markers managed by a manager have been added to or removed from the map. The event handler function should be prepared to accept two arguments. The fist one is the rectangle definining the bounds of the visible grid. The second one carries the number of markers currently shown on the map.

class MarkerManagerOptions

This class represents optional arguments to the MarkerManager constructor. It has no constructor, but is instantiated as object literal.

Properties

Properties Type Description
borderPadding Number Specifies, in pixels, the extra padding outside the map's current viewport monitored by a manager. Markers that fall within this padding are added to the map, even if they are not fully visible.
maxZoom Number Sets the maximum zoom level monitored by a marker manager. If not given, the manager assumes the maximum map zoom level. This value is also used when markers are added to the manager without the optional maxZoom parameter.
trackMarkers Boolean Indicates whether or not a marker manager should track markers' movements. If you wish to move managed markers using the setPoint method, this option should be set to true. The default value is false.