Marker manager is an interface between the map and the user,
designed to manage adding and removing many points when the viewport changes.
How it Works:
The MarkerManager places its markers onto a grid, similar to the map tiles.
When the user moves the viewport, it computes which grid cells have
entered or left the viewport, and shows or hides all the markers in those
cells.
(If the users scrolls the viewport beyond the markers that are loaded,
no markers will be visible until the EVENT_moveend
triggers an update.)
In practical consequences, this allows 10,000 markers to be distributed over
a large area, and as long as only 100-200 are visible in any given viewport,
the user will see good performance corresponding to the 100 visible markers,
rather than poor performance corresponding to the total 10,000 markers.
Note that some code is optimized for speed over space,
with the goal of accommodating thousands of markers.
For a description and examples of how to use this library, check out the how-to.
| Constructor | Description |
|---|---|
GridBounds(bounds:) |
Helper class to create a bounds of INT ranges. |
| Methods | Return Value | Description |
|---|---|---|
containsPoint(point:Point) |
Boolean |
Returns true if this bounds (inclusively) contains the given point. |
equals(gridBounds:GridBounds) |
Boolean |
Returns true if this bounds equal the given bounds. |
| Methods | Return Value | Description |
|---|---|---|
addMarker(marker:Marker, minZoom:Number, opt_maxZoom:Number) |
None |
Add a single marker to the map. |
addMarkers(markers:Array of Marker, minZoom:Number, opt_maxZoom:Number) |
None |
Add many markers at once. Does not actually update the map, just the internal grid. |
clearMarkers() |
None |
Removes all markers in the manager, and removes any visible markers from the map. |
getMarker(lat:Number, lng:Number, zoom:Number) |
GMarker |
Returns a marker given latitude, longitude and zoom. If the marker does not exist, the method will return a new marker. If a new marker is created, it will NOT be added to the manager. |
getMarkerCount(zoom:Number) |
None |
Calculates the total number of markers potentially visible at a given zoom level. |
hide() |
None |
Hides the manager if it's currently visible |
initialize(map:, opt_opts:) |
None |
|
isHidden() |
Boolean |
Returns true if the manager is hidden. Otherwise returns false. |
refresh() |
None |
Refresh forces the marker-manager into a good state.
|
removeMarker(marker:GMarker) |
None |
Removes marker from the manager and from the map (if it's currently visible). |
show() |
None |
Shows the manager if it's currently hidden. |
toggle() |
None |
Toggles the visibility of the manager. |
visible() |
Boolean |
Is this layer visible? Returns visibility setting |
This class represents optional arguments to the MarkerManager
constructor. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.
| 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=false |
Boolean |
Indicates whether or not a marker
manager should track markers' movements. If you wish to move managed
markers using the setPoint/setLatLng methods,
this option should be set to true. |
| Constructor | Description |
|---|---|
ProjectionHelperOverlay(map:Map) |
Projection overlay helper. Helps in calculating that markers get into the right grid. |
| Methods | Return Value | Description |
|---|---|---|
draw() |
None |
Draw function only triggers a ready event for MarkerManager to know projection can proceed to initialize. |