UNPKG

2gis-maps

Version:

Interactive 2GIS maps API, based on Leaflet

233 lines (226 loc) 9.16 kB
<h2 id="meta-layers">Meta Layers</h2><p>Allows you to create additional layers of meta information and add them to the map.</p> <p><dl class="api-incut"><ul class="page-contents"><li><a href="#dgmeta.layer">DG.Meta.layer</a><ul><li><a href="#creation">Creation</a></li><li><a href="#options">Options</a></li><li><a href="#events">Events</a></li><li><a href="#methods">Methods</a></li></ul></li><li><a href="#dgmeta.origin">DG.Meta.origin</a><ul><li><a href="#creation-1">Creation</a></li><li><a href="#options-1">Options</a></li><li><a href="#methods-1">Methods</a></li></ul></dl></p> <h3 id="dgmeta.layer">DG.Meta.layer</h3><p>Inherits from <a href="/doc/maps/en/manual/base-classes#dglayer"><code>DG.Layer</code></a>.</p> <h4 id="creation">Creation</h4><table> <thead> <tr> <th>Factory</th> <th>Usage</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>DG.Meta.layer</b>( <nobr>&lt;String&gt; <i>source</i>,</nobr> <nobr>&lt;<a href="#options">DG.Meta.layer options</a>&gt; <i>options?</i> )</nobr> </code></td> <td><code>DG.Meta.layer(&hellip;)</code></td> <td>Creates additional layer with meta-information. Takes the source URL as a parameter with which the tiles of an additional layer are available.</td> </tr> </tbody> </table> <h4 id="options">Options</h4><table> <thead> <tr> <th>Option</th> <th>Type</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>tileSize</b></code></td> <td><code>Number</code></td> <td><code>256</code></td> <td>The tile size (width and height in pixels, it is assumed that the tile is square).</td> </tr> <tr> <td><code><b>minZoom</b></code></td> <td><code>Number</code></td> <td><code>0</code></td> <td>The minimum zoom level.</td> </tr> <tr> <td><code><b>maxZoom</b></code></td> <td><code>Number</code></td> <td><code>18</code></td> <td>The maximum zoom level.</td> </tr> <tr> <td><code><b>zoomOffset</b></code></td> <td><code>Number</code></td> <td><code>0</code></td> <td>Value which will shift the zoom level in the tile&#39;s address.</td> </tr> <tr> <td><code><b>eventBubbling</b></code></td> <td><code>String</code></td> <td><code><span class="string">&#39;transparent&#39;</span>||<span class="string">&#39;layer&#39;</span></td> <td>The way in which meta-layer handles events. Accepts values <b>layer</b> or <b>transparent</b> (default):<ul class="list-v-disc"><li>transparent &mdash; meta-layer receives all of the events and carry them to the map</li><li>layer &mdash; meta-layer receives all of the events and stops them after processing</li></ul></td> </tr> </tbody> </table> <h4 id="events">Events</h4><p>You can subscribe to the following events using <a href="/doc/maps/en/manual/base-classes#dgevented">these</a> methods.</p> <table> <thead> <tr> <th>Event</th> <th>Data</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>mouseover</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code> <td>Called when you hover the mouse over the additional layer object.</td> </tr> <tr> <td><code><b>mouseout</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code> <td>Called when the mouse cursor leaves the bounds of an additional layer object.</td> </tr> <tr> <td><code><b>mousemove</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code></td> <td>Called when the mouse cursor moves over an additional layer object.</td> </tr> <tr> <td><code><b>click</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code></td> <td>Called when the mouse click in the additional layer.</td> </tr> <tr> <td><code><b>dblclick</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code></td> <td>Called when the mouse double-click in the additional layer.</td> </tr> <tr> <td><code><b>mousedown</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code></td> <td>Called when the mouse button is pressed while the cursor is over the additional layer.</td> </tr> <tr> <td><code><b>contextmenu</b></code></td> <td><code><a href="/doc/maps/en/manual/base-classes#metaevent">MetaEvent</a></code></td> <td>Called when you click the right mouse button in the additional layer.</td> </tr> </tbody> </table> <h4 id="methods">Methods</h4><table> <thead> <tr> <th>Method</th> <th>Returns</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>getOrigin</b>()</code></td> <td><code>Object</code></td> <td>Returns origin-instance of additional layer.</td> </tr> </tbody> </table> <h3 id="dgmeta.origin">DG.Meta.origin</h3><p>Works with the meta data of a layer, inherits from <a href="/doc/maps/en/manual/base-classes#dgclass"><code>DG.Class</code></a>.</p> <h4 id="creation-1">Creation</h4><table> <thead> <tr> <th>Factory</th> <th>Usage</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>DG.Meta.origin</b>( <nobr>&lt;String&gt; <i>source</i>,</nobr> <nobr>&lt;DG.Meta.layer options&gt; <i>options?</i> )</nobr> </code></td> <td><code>DG.Meta.origin(&hellip;)</code></td> <td>Creates an instance for work with the meta layer data. Takes the source URL as a parameter with which the tiles of an additional layer are available.</td> </tr> </tbody> </table> <h4 id="options-1">Options</h4><table> <thead> <tr> <th>Option</th> <th>Type</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>subdomains</b></code></td> <td><code>String</code> или <code>String[]</code></td> <td><code>&#39;0123&#39;</code></td> <td>Tile service subdomains. Can be sent as one string (where each letter &mdash; is a subdomain name) or as an array of strings.</td> </tr> <tr> <td><code><b>dataFilter</b></code></td> <td><code>Function</code></td> <td><code>null</code></td> <td>Optional parameter, which takes a function to filter or convert the meta data received from the server.</td> </tr> </tbody> </table> <h4 id="methods-1">Methods</h4><table> <thead> <tr> <th>Method</th> <th>Returns</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code><b>getTileData</b>( <nobr>&lt;Object&gt; <i>coord</i>)</nobr> </code> <td><code>Object</code></td> <td>Returns the metadata of the meta layer for the specified tile.</td> </tr> <tr> <td><code><b>setTileData</b>( <nobr>&lt;String&gt;/&lt;Object&gt; <i>coord</i>,</nobr> <nobr>&lt;Object&gt; <i>data</i>)</nobr> </code> <td><code>this</code></td> <td>Assigns data for the tile with the coord key.</td> </tr> <tr> <td><code><b>flush</b>()</code></td> <td><code>this</code></td> <td>Clear cached data for all tiles.</td> </tr> <tr> <td><code><b>setURL</b>( <nobr>&lt;String&gt; <i>url</i>,</nobr> <nobr>&lt;Boolean&gt; <i>flush?</i>)</nobr> </code> <td><code>this</code></td> <td>Sets the url used to get the meta data. If the parameter flush=true, the cached data will be cleared.</td> </tr> <tr> <td><code><b>getTileKey</b>( <nobr>&lt;Object&gt; <i>coord</i>)</nobr> </code> <td><code>String</code></td> <td>Returns the key of the tile as a string.</td> </tr> </tbody> </table>