UNPKG

@mapgis/webclient-common

Version:

mapgis ES6 format for igserver

1,878 lines (614 loc) 28 kB
<header id="page-title" class="page-title"> <span class="page-title-main">类名</span> <span class="page-title-sub">FeatureSet</span> </header> <section> <article> <div class="container-overview"> <div class='vertical-section'> <div class="members"> <div class="member"> <h4 class="name" id="FeatureSet"> <a class="href-link" href="#FeatureSet">#</a> <span class="code-name" id="FeatureSet" style="font-size:30px"> new FeatureSet<span class="signature">(options)</span> </span> </h4> <div class="description"> <p>要素集合类,示例如下:<a id='add-FeatureSet'>[初始化要素集合对象]</a> <br><br>[ES5引入方式]:<br/> Zondy.FeatureSet() <br/> [ES6引入方式]:<br/> import { FeatureSet } from &quot;@mapgis/webclient-common&quot; <br/> <br/></p> </div> <h4>参数</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th style="min-width: 100px;">默认值</th> <th class="last">描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name" id="options"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="default"> </td> <td class="description last"><p>构造参数</p></td> </tr> <tr class="deep-level-1"> <td class="name" id="id"><code>id</code></td> <td class="type"> <span class="param-type">String</span> </td> <td class="default"> </td> <td class="description last"><p>要素集合的id,不给则给一个随机的默认id</p></td> </tr> <tr class="deep-level-1"> <td class="name" id="features"><code>features</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="default"> [] </td> <td class="description last"><p>要素数组</p></td> </tr> <tr class="deep-level-1"> <td class="name" id="spatialReference"><code>spatialReference</code></td> <td class="type"> <span class="param-type"><a link="SpatialReference.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="SpatialReference" SpatialReference.html>SpatialReference</a></span> </td> <td class="default"> new Zondy.SpatialReference('EPSG:4326') </td> <td class="description last"><p>要素集合的参考系, 默认为4326,当要素的几何对象上制定了参考系时,用要素上的;当要素的集合对象上没有指定参考系时,则使用该参考系</p></td> </tr> </tbody> </table> </div> <dl class="details"> </dl> <p class="summary"><h5>支持如下方法:</h5> <a href='#findFeatureById'>[1、通过ID寻找要素]</a><br/> <a href='#fromGeoJSON'>[3、从geoJSON对象中导入数据]</a><br/> <a href='#toGeoJSON'>[4、导出为GeoJSON数据]</a><br/> <a href='#fromArray'>[5、将一个要素数组对象转为要素集合]</a><br/> <a href='#toJSON'>[6、导出一个JSON对像]</a><br/> <a href='#clone'>[7、克隆并返回新的要素集合]</a><br/> <a href='#static fromJSON'>[8、通过传入的json构造并返回一个新的几何对象]</a><br/></p> <h5>示例</h5> <p class="code-caption"><h7 id='add-FeatureSet'>初始化要素集合对象</h7></p> <pre class="prettyprint"><code>// ES5引入方式 const { FeatureSet } = Zondy // ES6引入方式 import { FeatureSet } from "@mapgis/webclient-common" //创建要素集合 let featureSet = new FeatureSet({ //不填则创建一个随机的guid id: "你的id", //要素集合 features: [] })</code></pre> </div> </div> </div> </div> <div class='vertical-section'> <h3 id='member'>成员变量</h3> <h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量概述</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th>描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name"><code><a href="#features">features</a></code></td> <td class="name"> <code> <span class="param-type">Array</span> </code> </td> <td class="name"><code><p>要素数组 default []</p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#id">id</a></code></td> <td class="name"> <code> <span class="param-type">String</span> </code> </td> <td class="name"><code><p>要素集合的id default 随机id</p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#spatialReference">spatialReference</a></code></td> <td class="name"> <code> <span class="param-type"><a link="SpatialReference.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="SpatialReference" SpatialReference.html>SpatialReference</a></span> </code> </td> <td class="name"><code><p>要素集合的参考系 default new Zondy.SpatialReference('EPSG:4326')</p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#type">type</a></code></td> <td class="name"> <code> <span class="param-type">String</span> </code> </td> <td class="name"><code><p>该类的类型 default FeatureCollection</p></code></td> </tr> </tbody> </table> </div> <h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量详情</h4> <div class="members"> <div class="member"> <span class="method-parameter is-pulled-right"> <label>类型:</label> <span class="param-type">Array</span> </span> <h4 class="name" id="features"> <a class="href-link" href="#features">#</a> <span class="code-name"> features </span> </h4> <div class="description"> <p>要素数组 default []</p> </div> <dl class="details"> </dl> </div> <div class="member"> <span class="method-parameter is-pulled-right"> <label>类型:</label> <span class="param-type">String</span> </span> <h4 class="name" id="id"> <a class="href-link" href="#id">#</a> <span class="code-name"> id </span> </h4> <div class="description"> <p>要素集合的id default 随机id</p> </div> <dl class="details"> </dl> </div> <div class="member"> <span class="method-parameter is-pulled-right"> <label>类型:</label> <span class="param-type"><a link="SpatialReference.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="SpatialReference" SpatialReference.html>SpatialReference</a></span> </span> <h4 class="name" id="spatialReference"> <a class="href-link" href="#spatialReference">#</a> <span class="code-name"> spatialReference </span> </h4> <div class="description"> <p>要素集合的参考系 default new Zondy.SpatialReference('EPSG:4326')</p> </div> <dl class="details"> </dl> </div> <div class="member"> <span class="method-parameter is-pulled-right"> <label>类型:</label> <span class="param-type">String</span> </span> <h4 class="name" id="type"> <a class="href-link" href="#type">#</a> <span class='tag'>readonly</span> <span class="code-name"> type </span> </h4> <div class="description"> <p>该类的类型 default FeatureCollection</p> </div> <dl class="details"> </dl> </div> </div> </div> <div class='vertical-section'> <h3 id='function'>方法</h3> <h4 style="margin-top: 20px;margin-bottom: 20px;">方法概述</h4> <div class="members"> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>返回值类型</th> <th>描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name"><code><a href="#fromArray">fromArray</a></code></td> <td class="name"> <code> </code> </td> <td class="name"><code><p>将一个要素数组对象转为要素集合<a id='fromArray'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#fromGeoJSON">fromGeoJSON</a></code></td> <td class="name"> <code> </code> </td> <td class="name"><code><p>从geoJSON对象中导入数据,若要素id相同,则会覆盖当前要素的值<a id='fromGeoJSON'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#fromJSON">fromJSON</a></code></td> <td class="name"> <code> </code> </td> <td class="name"><code><p>通过传入的json构造并返回一个新的几何对象<a id='fromJSON'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#clone">clone</a></code></td> <td class="name"> <code> <span class="param-type"><a link="FeatureSet.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="FeatureSet" FeatureSet.html>FeatureSet</a></span> </code> </td> <td class="name"><code><p>克隆并返回新的要素集合<a id='clone'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#findFeatureById">findFeatureById</a></code></td> <td class="name"> <code> </code> </td> <td class="name"><code><p>通过ID寻找要素,若没有id,则在要素的attributes中查找<a id='findFeatureById'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#toGeoJSON">toGeoJSON</a></code></td> <td class="name"> <code> <span class="param-type">Object</span> </code> </td> <td class="name"><code><p>导出为GeoJSON数据<a id='toGeoJSON'></a></p></code></td> </tr> <tr class="deep-level-0"> <td class="name"><code><a href="#toJSON">toJSON</a></code></td> <td class="name"> <code> <span class="param-type">Object</span> </code> </td> <td class="name"><code><p>导出一个JSON对像<a id='toJSON'></a></p></code></td> </tr> </tbody> </table> </div> <h4 style="margin-top: 20px;margin-bottom: 20px;">方法详情</h4> <div class="member"> <h4 class="name" id=".fromArray"> <a class="href-link" href="#.fromArray">#</a> <span class='tag'>static</span> <span class="code-name" id="fromArray" style="font-size:30px"> fromArray<span class="signature">(features, featureSet)</span> </span> </h4> <div class="description"> <p>将一个要素数组对象转为要素集合<a id='fromArray'></a></p> </div> <h4>参数</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th class="last">描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name" id="features"><code>features</code></td> <td class="type"> <span class="param-type">Array.&lt;Object></span> | <span class="param-type"><a link="FeatureSet.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="FeatureSet" FeatureSet.html>FeatureSet</a></span> </td> <td class="description last"></td> </tr> <tr class="deep-level-0"> <td class="name" id="featureSet"><code>featureSet</code></td> <td class="type"> <span class="param-type"><a link="FeatureSet.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="FeatureSet" FeatureSet.html>FeatureSet</a></span> </td> <td class="description last"></td> </tr> </tbody> </table> </div> <dl class="details"> </dl> <div class='columns method-parameter'> <div class="column is-2"><label>返回值</label></div> <div class="column is-10"> <div class="columns"> <div class='param-desc column is-7'><p>FeatureSet 新的featureSet对象</p></div> </div> </div> </div> <h5>示例</h5> <p class="code-caption"><h7>将一个要素数组对象转为要素集合</h7></p> <pre class="prettyprint"><code>// ES5引入方式 const { FeatureSet } = Zondy // ES6引入方式 import { FeatureSet } from "@mapgis/webclient-common" featureSet = FeatureSet.fromArray( [ { "attributes": { "FID": 650, "CODE": "420000", "CAPNAME": "武汉市", "mpPerimeter": "38.93733309514808", "mpArea": "17.556751278282672", "mpLayer": "18", "NAME": "湖北省" }, "geometry": { "type": "Polygon", "coordinates": [[]] }, "symbol": null } ], new FeatureSet() )</code></pre> </div> <div class="member"> <h4 class="name" id=".fromGeoJSON"> <a class="href-link" href="#.fromGeoJSON">#</a> <span class='tag'>static</span> <span class="code-name" id="fromGeoJSON" style="font-size:30px"> fromGeoJSON<span class="signature">(geoJSON)</span> </span> </h4> <div class="description"> <p>从geoJSON对象中导入数据,若要素id相同,则会覆盖当前要素的值<a id='fromGeoJSON'></a></p> </div> <h4>参数</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th class="last">描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name" id="geoJSON"><code>geoJSON</code></td> <td class="type"> </td> <td class="description last"><p>geoJSON数据</p></td> </tr> </tbody> </table> </div> <dl class="details"> </dl> <h5>示例</h5> <p class="code-caption"><h7>从geoJSON对象中导入数据</h7></p> <pre class="prettyprint"><code>//数据格式参考https://geojson.org/ FeatureSet.fromGeoJSON({ //类型必须为FeatureCollection type: "FeatureCollection", //要素集合 features: [] })</code></pre> </div> <div class="member"> <h4 class="name" id=".fromJSON"> <a class="href-link" href="#.fromJSON">#</a> <span class='tag'>static</span> <span class="code-name" id="fromJSON" style="font-size:30px"> fromJSON<span class="signature">(json)</span> </span> </h4> <div class="description"> <p>通过传入的json构造并返回一个新的几何对象<a id='fromJSON'></a></p> </div> <h4>参数</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th class="last">描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name" id="json"><code>json</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"><p>JSON对象</p></td> </tr> </tbody> </table> </div> <dl class="details"> </dl> <h5>示例</h5> <p class="code-caption"><h7 id='fromJSON'>通过传入的json构造并返回一个新的几何对象</h7></p> <pre class="prettyprint"><code>// ES5引入方式 const { FeatureSet } = Zondy // ES6引入方式 import { FeatureSet } from "@mapgis/webclient-common" const json = { //不填则创建一个随机的guid id: "你的id", //要素集合 features: [] } const featureSet = new FeatureSet.fromJSON(json)</code></pre> </div> <div class="member"> <h4 class="name" id="clone"> <a class="href-link" href="#clone">#</a> <span class="code-name" id="clone" style="font-size:30px"> clone<span class="signature">()</span> </span> </h4> <div class="description"> <p>克隆并返回新的要素集合<a id='clone'></a></p> </div> <dl class="details"> </dl> <div class='columns method-parameter'> <div class="column is-2"><label>返回值</label></div> <div class="column is-10"> <div class="columns"> <div class='param-desc column is-7'><p>克隆后的新要素集合</p></div> <div class='column is-5 has-text-left'> <label>类型: </label> <span class="param-type"><a link="FeatureSet.html" onclick="getTypeHTML(event)" class="mapgis-link-name" title="FeatureSet" FeatureSet.html>FeatureSet</a></span> </div> </div> </div> </div> <h5>示例</h5> <p class="code-caption"><h7>克隆并返回新的要素集合</h7></p> <pre class="prettyprint"><code>let newFeatureSet = featureSet.clone();</code></pre> </div> <div class="member"> <h4 class="name" id="findFeatureById"> <a class="href-link" href="#findFeatureById">#</a> <span class="code-name" id="findFeatureById" style="font-size:30px"> findFeatureById<span class="signature">(id)</span> </span> </h4> <div class="description"> <p>通过ID寻找要素,若没有id,则在要素的attributes中查找<a id='findFeatureById'></a></p> </div> <h4>参数</h4> <div class="table-container"> <table class="params table"> <thead> <tr> <th>名称</th> <th>类型</th> <th class="last">描述</th> </tr> </thead> <tbody> <tr class="deep-level-0"> <td class="name" id="id"><code>id</code></td> <td class="type"> </td> <td class="description last"><p>要素ID</p></td> </tr> </tbody> </table> </div> <dl class="details"> </dl> <div class='columns method-parameter'> <div class="column is-2"><label>返回值</label></div> <div class="column is-10"> <div class="columns"> <div class='param-desc column is-7'><p>Feature 要素对象</p></div> </div> </div> </div> <h5>示例</h5> <p class="code-caption"><h7 id='findFeatureById'>通过ID寻找要素</h7></p> <pre class="prettyprint"><code>let feature = featureSet.findFeatureById("要素id");</code></pre> </div> <div class="member"> <h4 class="name" id="toGeoJSON"> <a class="href-link" href="#toGeoJSON">#</a> <span class="code-name" id="toGeoJSON" style="font-size:30px"> toGeoJSON<span class="signature">()</span> </span> </h4> <div class="description"> <p>导出为GeoJSON数据<a id='toGeoJSON'></a></p> </div> <dl class="details"> </dl> <div class='columns method-parameter'> <div class="column is-2"><label>返回值</label></div> <div class="column is-10"> <div class="columns"> <div class='param-desc column is-7'><p>geoJSON数据</p></div> <div class='column is-5 has-text-left'> <label>类型: </label> <span class="param-type">Object</span> </div> </div> </div> </div> <h5>示例</h5> <p class="code-caption"><h7>导出为GeoJSON数据</h7></p> <pre class="prettyprint"><code>let geojson = featureSet.toGeoJSON();</code></pre> </div> <div class="member"> <h4 class="name" id="toJSON"> <a class="href-link" href="#toJSON">#</a> <span class="code-name" id="toJSON" style="font-size:30px"> toJSON<span class="signature">()</span> </span> </h4> <div class="description"> <p>导出一个JSON对像<a id='toJSON'></a></p> </div> <dl class="details"> </dl> <div class='columns method-parameter'> <div class="column is-2"><label>返回值</label></div> <div class="column is-10"> <div class="columns"> <div class='param-desc column is-7'><p>JSON对像</p></div> <div class='column is-5 has-text-left'> <label>类型: </label> <span class="param-type">Object</span> </div> </div> </div> </div> </div> </div> </div> </article> </section>