UNPKG

googlemaps-v3-utility-library

Version:
380 lines (232 loc) 12.8 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>MarkerManager v3 v1.1 Reference</title> <link rel="stylesheet" type="text/css" href="http://code.google.com/css/codesite.css"></link> <link rel="stylesheet" type="text/css" href="../../util/docs/template/local_extensions.css"></link> </head> <body> <h1>MarkerManager v3</h1> <p> Marker manager is an interface between the map and the user, designed to manage adding and removing many points when the viewport changes. <br /><br /> <b>How it Works</b>:<br/> 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 <code>EVENT_moveend</code> 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.</p> <p>For a description and examples of how to use this library, check out the <a href="examples.html">how-to</a>.</p> <h2><a name="GridBounds"></a>class GridBounds</h2> <p></p> <h3>Constructor</h3> <table summary="class GridBounds - Constructor" width="90%"> <tbody> <tr> <th>Constructor</th> <th>Description</th> </tr> <tr class="odd"> <td><code>GridBounds(<span class="type">bounds:</span>)</code></td> <td>Helper class to create a bounds of INT ranges.</td> </tr> </tbody> </table> <h3>Methods</h3> <table summary="class GridBounds - Methods" width="90%"> <tbody> <tr> <th>Methods</th> <th>Return&nbsp;Value</th> <th>Description</th> </tr> <tr class="odd"> <td><code>containsPoint(<span class="type">point:Point</span>)</code></td> <td><code>Boolean</code></td> <td>Returns true if this bounds (inclusively) contains the given point.</td> </tr> <tr class="even"> <td><code>equals(<span class="type">gridBounds:GridBounds</span>)</code></td> <td><code>Boolean</code></td> <td>Returns true if this bounds equal the given bounds.</td> </tr> </tbody> </table> <h2><a name="MarkerManager"></a>class MarkerManager</h2> <p></p> <h3>Methods</h3> <table summary="class MarkerManager - Methods" width="90%"> <tbody> <tr> <th>Methods</th> <th>Return&nbsp;Value</th> <th>Description</th> </tr> <tr class="odd"> <td><code>addMarker(<span class="type">marker:Marker</span>, <span class="type">minZoom:Number</span>, <span class="type">opt_maxZoom:Number</span>)</code></td> <td><code>None</code></td> <td>Add a single marker to the map.</td> </tr> <tr class="even"> <td><code>addMarkers(<span class="type">markers:Array of Marker</span>, <span class="type">minZoom:Number</span>, <span class="type">opt_maxZoom:Number</span>)</code></td> <td><code>None</code></td> <td>Add many markers at once. Does not actually update the map, just the internal grid.</td> </tr> <tr class="odd"> <td><code>clearMarkers()</code></td> <td><code>None</code></td> <td>Removes all markers in the manager, and removes any visible markers from the map.</td> </tr> <tr class="even"> <td><code>getMarker(<span class="type">lat:Number</span>, <span class="type">lng:Number</span>, <span class="type">zoom:Number</span>)</code></td> <td><code>GMarker</code></td> <td>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.</td> </tr> <tr class="odd"> <td><code>getMarkerCount(<span class="type">zoom:Number</span>)</code></td> <td><code>None</code></td> <td>Calculates the total number of markers potentially visible at a given zoom level.</td> </tr> <tr class="even"> <td><code>hide()</code></td> <td><code>None</code></td> <td>Hides the manager if it's currently visible</td> </tr> <tr class="odd"> <td><code>initialize(<span class="type">map:</span>, <span class="type">opt_opts:</span>)</code></td> <td><code>None</code></td> <td></td> </tr> <tr class="even"> <td><code>isHidden()</code></td> <td><code>Boolean</code></td> <td>Returns true if the manager is hidden. Otherwise returns false.</td> </tr> <tr class="odd"> <td><code>refresh()</code></td> <td><code>None</code></td> <td>Refresh forces the marker-manager into a good state. <ol> <li>If never before initialized, shows all the markers.</li> <li>If previously initialized, removes and re-adds all markers.</li> </ol></td> </tr> <tr class="even"> <td><code>removeMarker(<span class="type">marker:GMarker</span>)</code></td> <td><code>None</code></td> <td>Removes marker from the manager and from the map (if it's currently visible).</td> </tr> <tr class="odd"> <td><code>show()</code></td> <td><code>None</code></td> <td>Shows the manager if it's currently hidden.</td> </tr> <tr class="even"> <td><code>toggle()</code></td> <td><code>None</code></td> <td>Toggles the visibility of the manager.</td> </tr> <tr class="odd"> <td><code>visible()</code></td> <td><code>Boolean</code></td> <td>Is this layer visible? Returns visibility setting</td> </tr> </tbody> </table> <h2><a name="MarkerManagerOptions"></a>class MarkerManagerOptions</h2> <p>This class represents optional arguments to the <code><a href="reference.html#_global_#MarkerManager">MarkerManager</a></code> constructor. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.</p> <h3>Properties</h3> <table summary="class MarkerManagerOptions - Properties" width="90%"> <tbody> <tr> <th>Properties</th> <th>Type</th> <th>Description</th> </tr> <tr class="odd"> <td><code>borderPadding</code></td> <td><code>Number</code></td> <td>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.</td> </tr> <tr class="even"> <td><code>maxZoom</code></td> <td><code>Number</code></td> <td>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 <code>maxZoom</code> parameter.</td> </tr> <tr class="odd"> <td><code>trackMarkers=false</code></td> <td><code>Boolean</code></td> <td>Indicates whether or not a marker manager should track markers' movements. If you wish to move managed markers using the <code>setPoint</code>/<code>setLatLng</code> methods, this option should be set to <code>true</code>.</td> </tr> </tbody> </table> <h2><a name="ProjectionHelperOverlay"></a>class ProjectionHelperOverlay</h2> <p></p> <h3>Constructor</h3> <table summary="class ProjectionHelperOverlay - Constructor" width="90%"> <tbody> <tr> <th>Constructor</th> <th>Description</th> </tr> <tr class="odd"> <td><code>ProjectionHelperOverlay(<span class="type">map:Map</span>)</code></td> <td>Projection overlay helper. Helps in calculating that markers get into the right grid.</td> </tr> </tbody> </table> <h3>Methods</h3> <table summary="class ProjectionHelperOverlay - Methods" width="90%"> <tbody> <tr> <th>Methods</th> <th>Return&nbsp;Value</th> <th>Description</th> </tr> <tr class="odd"> <td><code>draw()</code></td> <td><code>None</code></td> <td>Draw function only triggers a ready event for MarkerManager to know projection can proceed to initialize.</td> </tr> </tbody> </table> <h2><a name="ProjectionHelperOverlay#LatLngToPixel"></a>class LatLngToPixel</h2> <p></p> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-964209-4"; urchinTracker(); </script> </body> </html>