@mapgis/webclient-leaflet-plugin
Version:
开发时需要引入MapGIS Client for JavaScript(Leaflet)开发包;其中包括必备的 CSS 文件和 JS 文件;
288 lines (113 loc) • 4.76 kB
HTML
<header id="page-title" class="page-title">
<span class="page-title-main">类名</span>
<span class="page-title-sub">FeatureLayerUtil</span>
</header>
<section>
<article>
<div class="container-overview">
<div class='vertical-section'>
<div class="members">
<div class="member">
<h4 class="name" id="FeatureLayerUtil">
<a class="href-link" href="#FeatureLayerUtil">#</a>
<span class="code-name" id="FeatureLayerUtil" style="font-size:30px">
new FeatureLayerUtil<span class="signature">()</span>
</span>
</h4>
<div class="description">
<p>要素图层工具类(Leaflet)</p>
</div>
<dl class="details">
</dl>
</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="#convertFeature">convertFeature</a></code></td>
<td class="name">
<code>
</code>
</td>
<td class="name"><code><p>将Common的要素对象转为Leaflet的要素对象</p></code></td>
</tr>
</tbody>
</table>
</div>
<h4 style="margin-top: 20px;margin-bottom: 20px;">成员变量详情</h4>
<div class="members">
<div class="member">
<h4 class="name" id=".convertFeature">
<a class="href-link" href="#.convertFeature">#</a>
<span class='tag'>static</span>
<span class="code-name">
convertFeature
</span>
</h4>
<div class="description">
<p>将Common的要素对象转为Leaflet的要素对象</p>
</div>
<dl class="details">
</dl>
<h5>示例</h5>
<p class="code-caption"><h5>添加要素图层-原生接口</h5></p>
<pre class="prettyprint"><code>// ES5引入方式
const { IGSFeatureLayer } = zondy.Layer
const { FeatureLayerUtil, leaflet } = zondy
const { SimpleFillSymbol } = zondy.Symbol
// ES6引入方式
import * as leaflet from '@mapgis/leaflet'
import { IGSFeatureLayer,SimpleFillSymbol } from "@mapgis/webclient-common"
import { FeatureLayerUtil } from "@mapgis/webclient-leaflet-plugin"
// 通过Common库创建一个要素图层对象
const featureLayer = new IGSFeatureLayer({
// 服务基地址
url: 'http://{ip}:{port}/igs/rest/services/{服务名}/FeatureServer'
})
// 查询要素,并绘制要素
featureLayer.queryFeatures({
// 指定要查询的子图层ID
layerId: '0',
// 指定查询结果的坐标系
outSrs: 'EPSG:4326',
// 指定查询数量
resultRecordCount: 100000
}).then((res) => {
// 创建一个Leaflet的要素图层
const featureLayerLeaflet = leaflet.featureGroup()
// 获取Leaflet的地图视图对象
const mapView = view.getInnerView()
// 添加要素图层
featureLayerLeaflet.addTo(mapView)
// 获取查询到的要素
const features = res.features
// 循环绘制要素
features.forEach((feature) => {
// 指定绘制要素的符号,根据不同几何类型设置不同的符号,示例中使用的是区几何
feature.symbol = new SimpleFillSymbol({
color: 'rgba(244, 122, 31, 0.5)'
})
// 将要素对象转为Leaflet的几何对象
const graphic = FeatureLayerUtil.convertFeature(feature)
// 添加并绘制几何对象
featureLayerLeaflet.addLayer(graphic)
})
})</code></pre>
</div>
</div>
</div>
</article>
</section>