geojson docs

This commit is contained in:
Mourner 2011-06-15 11:56:45 +03:00
parent 2ce83227f6
commit 1d7e23375a

View File

@ -87,7 +87,7 @@
<ul>
<li><a href="#layergroup" class="nodocs">LayerGroup</a></li>
<li><a href="#featuregroup" class="nodocs">FeatureGroup</a></li>
<li><a href="#geojson" class="nodocs">GeoJSON</a></li>
<li><a href="#geojson">GeoJSON</a></li>
</ul>
<h4>Basic types</h4>
<ul>
@ -1486,6 +1486,87 @@ map.addLayer(polyline);</code></pre>
</table>
<h2 id="geojson">L.GeoJSON</h2>
<p>Represents a <a href="http://geojson.org/geojson-spec.html">GeoJSON</a> layer. Allows you to parse GeoJSON data and display on the map. Extends <a href="#layergroup">LayerGroup</a>.</p>
<pre><code class="javascript">var geojson = new L.GeoJSON(geojsonObj);
map.addLayer(geojson);</code></pre>
<h3>Constructor</h3>
<table>
<tr>
<th>Constructor</th>
<th>Description</th>
</tr>
<tr>
<td><code>L.GeoJSON( &lt;Object&gt;&nbsp;<i>geojson?</i>, &lt;<a href="geojson-options">GeoJSON options</a>&gt;&nbsp;<i>options?</i>&nbsp;)</code></td>
<td>Creates a GeoJSON layer. Optionally accepts an object in <a href="http://geojson.org/geojson-spec.html">GeoJSON format</a> to display on the map (you can alternatively add it with <code>addGeoJSON</code> method) and an options object.</td>
</tr>
</table>
<h3 id="geojson-options">Options</h3>
<table>
<tr>
<th>Option</th>
<th>Type</th>
<th>Default value</th>
<th>Description</th>
</tr>
<tr id="geojson-pointtolayer">
<td><code>pointToLayer</code></td>
<td><code>Function</code></td>
<td><code>null</code></td>
<td>Function of the form <code>(LatLng)->ILayer</code> that will be used for creating layers for GeoJSON points (if not specified, markers will be created).</td>
</tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<th>Method</th>
<th>Returns</th>
<th>Description</th>
</tr>
<tr>
<td><code>addGeoJSON( &lt;Object&gt;&nbsp;<i>geojson</i>&nbsp;)</code></td>
<td><code>Boolean</code></td>
<td>Adds a GeoJSON object to the layer.</td>
</tr>
</table>
<h3>Static methods</h3>
<table>
<tr>
<th>Method</th>
<th>Returns</th>
<th>Description</th>
</tr>
<tr>
<td><code>geometryToLayer( &lt;Object&gt;&nbsp;<i>geojson</i>, &lt;<a href="#geojson-pointtolayer">Function</a>&gt;&nbsp;<i>pointToLayer?</i>&nbsp;)</code></td>
<td><code>ILayer</code></td>
<td>Creates a layer from a given GeoJSON geometry.</td>
</tr>
<tr>
<td><code>coordsToLatlng( &lt;Array&gt;&nbsp;<i>coords</i>&nbsp;)</code></td>
<td><code><a href="#latlng">LatLng</a></code></td>
<td>Creates a LatLng object from an array of 2 numbers used in GeoJSON for points.</td>
</tr>
<tr>
<td><code>coordsToLatlngs( &lt;Array&gt;&nbsp;<i>coords</i>, &lt;Number&gt;&nbsp;<i>levelsDeep?</i>&nbsp;)</code></td>
<td><code>Array</code></td>
<td>Creates a multidimensional array of LatLng objects from a GeoJSON coordinates array. <code>levelsDeep</code> specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default).</td>
</tr>
</table>
<h2 id="latlng">L.LatLng</h2>
<p>Represents a geographical point with a certain latitude and longitude.</p>