@mapgis/webclient-mapboxgl-plugin 10.3.4 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -124
- package/dist/es5/webclient-common.min.js +90 -0
- package/dist/es5/webclient-mapboxgl-plugin.min.js +1 -0
- package/dist/webclient-mapboxgl-plugin-es6.min.js +1 -0
- package/documention/EchartsLayer.html +379 -0
- package/documention/MapViewMapboxgl.html +3587 -0
- package/documention/Popup.html +1523 -0
- package/documention/Screenshot.html +1089 -0
- package/documention/SketchEditorMapboxgl.html +3383 -0
- package/documention/document_ArcGISVectorTileLayerView.js.html +265 -0
- package/documention/document_EchartsLayerView.js.html +246 -0
- package/documention/document_GraphicsLayerView.js.html +314 -0
- package/documention/document_IGSFeatureLayerView.js.html +218 -0
- package/documention/document_IGSMapImageLayerView.js.html +240 -0
- package/documention/document_IGSTileLayerView.js.html +236 -0
- package/documention/document_IGSVectorTileLayerView.js.html +264 -0
- package/documention/document_MapVLayerView.js.html +247 -0
- package/documention/document_WMSLayerView.js.html +240 -0
- package/documention/document_WMTSLayerView.js.html +234 -0
- package/documention/document_WebTileLayerView.js.html +240 -0
- package/documention/document_support_FeatureRenderView.js.html +682 -0
- package/documention/document_support_MapboxglGraphicsLayer.js.html +1184 -0
- package/documention/document_support_SourceMetaData.js.html +223 -0
- package/documention/document_support_Utils.js.html +624 -0
- package/documention/document_support_mapbox_mapboxCustomUtil.js.html +322 -0
- package/documention/global.html +252 -0
- package/documention/index.html +251 -0
- package/documention/module-%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%8F%AF%E8%A7%86%E5%8C%96.MapvLayer.html +445 -0
- package/documention/scripts/app.min.js +1 -0
- package/documention/scripts/linenumber.js +26 -0
- package/documention/scripts/search.js +45 -0
- package/documention/scripts/sideBar.js +11 -0
- package/documention/sketchEditor_SketchEditorMapboxgl.js.html +875 -0
- package/documention/styles/anchor.png +0 -0
- package/documention/styles/app.min.css +1 -0
- package/documention/styles/c.png +0 -0
- package/documention/styles/iframe.css +29 -0
- package/documention/styles/m.png +0 -0
- package/documention/styles/prettify-jsdoc.css +111 -0
- package/documention/styles/prettify-tomorrow.css +132 -0
- package/documention/styles/reset.css +44 -0
- package/documention/styles/up-arrow.png +0 -0
- package/documention/tutorial-1./345/277/253/351/200/237/345/205/245/351/227/250.html +165 -0
- package/documention/util_ConvertRendererToStyleLayerUtil.js.html +844 -0
- package/documention/util_MapboxglFeatureRender.js.html +225 -0
- package/documention/util_MapboxglPlugin.js.html +284 -0
- package/documention/view_MapViewMapboxgl.js.html +1882 -0
- package/documention/view_utils_ArcGISVectorTileLayerUtil.js.html +382 -0
- package/documention/view_utils_EchartsLayerUtil.js.html +194 -0
- package/documention/view_utils_IGSMapImageUtil.js.html +373 -0
- package/documention/view_utils_IGSTileLayerUtil.js.html +285 -0
- package/documention/view_utils_IGSVectorTileLayerUtil.js.html +379 -0
- package/documention/view_utils_MapVLayerUtil.js.html +197 -0
- package/documention/view_utils_Popup.js.html +525 -0
- package/documention/view_utils_Screenshot.js.html +320 -0
- package/documention/view_utils_WMSLayerUtil.js.html +337 -0
- package/documention/view_utils_WMTSLayerUtil.js.html +331 -0
- package/documention/view_utils_WebTileLayerUtil.js.html +284 -0
- package/documention/view_utils_echarts_EchartsLayerPlugin.js.html +419 -0
- package/documention/view_utils_mapV_MapVLayerPlugin.js.html +527 -0
- package/documention/view_utils_mapV_MapvBaseLayer.js.html +477 -0
- package/documention/view_utils_support_rasterLayerUtil.js.html +244 -0
- package/documention/view_utils_support_vectorLayerUtil.js.html +503 -0
- package/package.json +20 -20
- package/core/Base.js +0 -15
- package/core/index.js +0 -5
- package/index.js +0 -6
- package/overlay/D3Layer.js +0 -108
- package/overlay/EchartsLayer.js +0 -242
- package/overlay/ElsCubeLayer.js +0 -125
- package/overlay/MapvLayer.js +0 -296
- package/overlay/StreamLayer.js +0 -83
- package/overlay/TimeSpaceCubeLayer.js +0 -135
- package/overlay/dthree/mapbox-d3.css +0 -9
- package/overlay/echarts/MapCoordSys.js +0 -105
- package/overlay/echarts/MapModel.js +0 -0
- package/overlay/echarts/MapView.js +0 -0
- package/overlay/echarts/index.js +0 -4
- package/overlay/index.js +0 -31
- package/overlay/mapv/MapvBaseLayer.js +0 -299
- package/overlay/mapv/index.js +0 -5
- package/overlay/stream/GeojsonStreamLayer.js +0 -135
- package/overlay/stream/MapvStreamLayer.js +0 -79
- package/overlay/stream/index.js +0 -3
- package/overlay/stream/popup.css +0 -31
- package/service/index.js +0 -1
- package/service/socket/ISocketService.js +0 -121
- package/service/socket/SocketEvent.js +0 -50
- package/service/socket/SocketService.js +0 -90
- package/util/Evented.js +0 -295
- package/util/Util.js +0 -348
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
<html lang="en">
|
|
5
|
+
|
|
6
|
+
<head>
|
|
7
|
+
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title>Client for JavaScript document/support/Utils.js</title>
|
|
11
|
+
<!--[if lt IE 9]>
|
|
12
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
13
|
+
<![endif]-->
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
|
16
|
+
<link type="text/css" rel="stylesheet" href="">
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<body class="layout small-header">
|
|
24
|
+
<div id="stickyNavbarOverlay"></div>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<div class="top-nav">
|
|
28
|
+
<div class="inner">
|
|
29
|
+
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
|
30
|
+
<span aria-hidden="true"></span>
|
|
31
|
+
<span aria-hidden="true"></span>
|
|
32
|
+
<span aria-hidden="true"></span>
|
|
33
|
+
</a>
|
|
34
|
+
<div class="logo">
|
|
35
|
+
|
|
36
|
+
<h1> MapGIS Client for JavaScript API</h1>
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
<div class="menu">
|
|
41
|
+
|
|
42
|
+
<div class="navigation">
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
<a
|
|
46
|
+
class="link user-link "
|
|
47
|
+
href="/static/modules/common/api/common-mapgis/index.html"
|
|
48
|
+
>
|
|
49
|
+
Common
|
|
50
|
+
</a>
|
|
51
|
+
|
|
52
|
+
<a
|
|
53
|
+
class="link user-link "
|
|
54
|
+
href="/static/modules/cesium/api/cesium-mapgis/index.html"
|
|
55
|
+
>
|
|
56
|
+
Cesium
|
|
57
|
+
</a>
|
|
58
|
+
|
|
59
|
+
<a
|
|
60
|
+
class="link user-link "
|
|
61
|
+
href="/static/modules/mapboxgl/api/mapboxgl-mapgis/index.html"
|
|
62
|
+
>
|
|
63
|
+
MapboxGL
|
|
64
|
+
</a>
|
|
65
|
+
|
|
66
|
+
<a
|
|
67
|
+
class="link user-link "
|
|
68
|
+
href="/static/modules/leaflet/api/leaflet-mapgis/index.html"
|
|
69
|
+
>
|
|
70
|
+
Leaflet
|
|
71
|
+
</a>
|
|
72
|
+
|
|
73
|
+
<a
|
|
74
|
+
class="link user-link "
|
|
75
|
+
href="/static/modules/openlayers/api/openLayers-mapgis/index.html"
|
|
76
|
+
>
|
|
77
|
+
OpenLayers
|
|
78
|
+
</a>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div id="main">
|
|
88
|
+
<div
|
|
89
|
+
class="sidebar "
|
|
90
|
+
id="sidebarNav"
|
|
91
|
+
>
|
|
92
|
+
<div>
|
|
93
|
+
<span class="mapgis-api-document-span"><a href="index.html">API文档</a></span>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div class="search-wrapper">
|
|
97
|
+
<input id="search" type="text" placeholder="搜索文档..." class="input">
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<nav>
|
|
101
|
+
|
|
102
|
+
<div class="category"><div style="font-weight: bold;vertical-align: middle;padding: 0.4rem 0;" class="mapgis-menu-span"><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/m.png" alt="">undefined</div><ul class="mapgis-sidebar-menus"><li><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/c.png" alt=""><a href="Popup.html">Popup</a><span style="display: none;"><p>二维场景信息弹窗(leaflet引擎)
|
|
103
|
+
参考示例:
|
|
104
|
+
<a href='#MapView'>[初始化二维场景视图]</a>
|
|
105
|
+
[ES6引入方式]:<br/>
|
|
106
|
+
import { Popup } from '@mapgis/webclient-leaflet-plugin' <br/>
|
|
107
|
+
自定义样式说明:<br/>
|
|
108
|
+
zondy-popup__content 弹窗容器样式<br/>
|
|
109
|
+
zondy-popup__tip 弹窗对话框箭头样式<br/>
|
|
110
|
+
zondy-popup__header 弹窗头部样式<br/>
|
|
111
|
+
zondy-popup__content 弹窗主体样式<br/>
|
|
112
|
+
zondy-popup__footer 弹窗底部样式<br/></p></span></li></ul><div style="font-weight: bold;vertical-align: middle;padding: 0.4rem 0;" class="mapgis-menu-span"><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/m.png" alt="">undefined</div><ul class="mapgis-sidebar-menus"><li><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/c.png" alt=""><a href="Screenshot.html">Screenshot</a><span style="display: none;"><p>打印工具</p></span></li></ul><div style="font-weight: bold;vertical-align: middle;padding: 0.4rem 0;" class="mapgis-menu-span"><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/m.png" alt="">草图编辑模块</div><ul class="mapgis-sidebar-menus"><li><img style="width: 20px;margin-right: 6px;vertical-align: middle;" src="./styles/c.png" alt=""><a href="SketchEditorMapboxgl.html">SketchEditorMapboxgl</a><span style="display: none;"><p>二维场景草图编辑类<br/>
|
|
113
|
+
<br>[ES5引入方式]:<br/>
|
|
114
|
+
const { SketchEditorMapboxgl } = Zondy <br/>
|
|
115
|
+
[ES6引入方式]:<br/>
|
|
116
|
+
import { SketchEditorMapboxgl } from "@mapgis/webclient-leaflet-plugin" <br/></p></span></li></ul></div>
|
|
117
|
+
|
|
118
|
+
</nav>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="core" id="main-content-wrapper">
|
|
121
|
+
<div class="content">
|
|
122
|
+
<header id="page-title" class="page-title">
|
|
123
|
+
<span class="page-title-main">类名</span>
|
|
124
|
+
<span class="page-title-sub">document/support/Utils.js</span>
|
|
125
|
+
</header>
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
<section>
|
|
132
|
+
<article>
|
|
133
|
+
<pre class="prettyprint source linenums"><code>import {
|
|
134
|
+
Color,
|
|
135
|
+
defaultValue,
|
|
136
|
+
GeometryType,
|
|
137
|
+
SimpleFillSymbol,
|
|
138
|
+
SimpleLineSymbol,
|
|
139
|
+
SimpleMarkerSymbol,
|
|
140
|
+
Symbol,
|
|
141
|
+
UniqueValueRenderer
|
|
142
|
+
} from '@mapgis/webclient-common'
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 获取圆形聚类的paint样式
|
|
146
|
+
* @param {ClusterRenderer} renderer 聚类渲染器对象
|
|
147
|
+
* @param {Object} options 额外参数
|
|
148
|
+
* @param {Number} [options.opacity = 1] 图层透明度
|
|
149
|
+
* @return {Object} paint mapbox的圆形聚类的paint样式
|
|
150
|
+
* */
|
|
151
|
+
function getClusterCirclePaint(renderer, options) {
|
|
152
|
+
options = defaultValue(options, {})
|
|
153
|
+
// 图层透明度
|
|
154
|
+
options.opacity = defaultValue(options.opacity, 1)
|
|
155
|
+
// 聚类分段参数
|
|
156
|
+
const clusterInfos = renderer.clusterInfos
|
|
157
|
+
// 默认样式
|
|
158
|
+
const defaultSymbol = renderer.defaultSymbol
|
|
159
|
+
// mapbox的圆形聚类的paint样式
|
|
160
|
+
const paint = {
|
|
161
|
+
// 设置圆形几何的填充颜色
|
|
162
|
+
'circle-color': ['step', ['get', 'point_count']],
|
|
163
|
+
// 圆形几何的填充颜色的透明度
|
|
164
|
+
'circle-opacity': ['step', ['get', 'point_count']],
|
|
165
|
+
// 设置圆形几何的半径
|
|
166
|
+
'circle-radius': ['step', ['get', 'point_count']],
|
|
167
|
+
// 设置外边线颜色
|
|
168
|
+
'circle-stroke-color': ['step', ['get', 'point_count']],
|
|
169
|
+
// 设置外边线透明度
|
|
170
|
+
'circle-stroke-opacity': ['step', ['get', 'point_count']],
|
|
171
|
+
// 设置外边线宽度
|
|
172
|
+
'circle-stroke-width': ['step', ['get', 'point_count']]
|
|
173
|
+
}
|
|
174
|
+
for (let i = 0; i < clusterInfos.length; i++) {
|
|
175
|
+
// 设置圆形几何的填充颜色
|
|
176
|
+
const _color = Color.fromColor(clusterInfos[i].symbol.color)
|
|
177
|
+
paint['circle-color'].push(_color.toCssRGBAString())
|
|
178
|
+
paint['circle-color'].push(clusterInfos[i].maxValue)
|
|
179
|
+
// 设置透明度,图层透明度*符号透明度,才是最终的透明度
|
|
180
|
+
paint['circle-opacity'].push(_color.alpha * options.opacity)
|
|
181
|
+
paint['circle-opacity'].push(clusterInfos[i].maxValue)
|
|
182
|
+
// 设置圆形几何的半径
|
|
183
|
+
paint['circle-radius'].push(clusterInfos[i].symbol.size)
|
|
184
|
+
paint['circle-radius'].push(clusterInfos[i].maxValue)
|
|
185
|
+
// 获取外边线样式
|
|
186
|
+
const _outline = Symbol.fromJSON(clusterInfos[i].symbol.outline)
|
|
187
|
+
// 设置外边线颜色
|
|
188
|
+
paint['circle-stroke-color'].push(_outline.color.toCssRGBAString())
|
|
189
|
+
paint['circle-stroke-color'].push(clusterInfos[i].maxValue)
|
|
190
|
+
// 设置透明度,图层透明度*符号透明度,才是最终的透明度
|
|
191
|
+
paint['circle-stroke-opacity'].push(_outline.color.alpha * options.opacity)
|
|
192
|
+
paint['circle-stroke-opacity'].push(clusterInfos[i].maxValue)
|
|
193
|
+
// 设置外边线宽度
|
|
194
|
+
paint['circle-stroke-width'].push(_outline.width)
|
|
195
|
+
paint['circle-stroke-width'].push(clusterInfos[i].maxValue)
|
|
196
|
+
}
|
|
197
|
+
// 下面这些是必填项
|
|
198
|
+
// 超出最大数值时的填充颜色
|
|
199
|
+
const _defaultColor = Color.fromColor(defaultSymbol.color)
|
|
200
|
+
paint['circle-color'].push(_defaultColor.toCssRGBAString())
|
|
201
|
+
paint['circle-opacity'].push(1)
|
|
202
|
+
// 超出最大数值时的几何的半径
|
|
203
|
+
paint['circle-radius'].push(defaultSymbol.size)
|
|
204
|
+
// 超出最大数值时的外边线样式
|
|
205
|
+
const _defaultOutline = Symbol.fromJSON(defaultSymbol.outline)
|
|
206
|
+
paint['circle-stroke-color'].push(_defaultOutline.color.toCssRGBAString())
|
|
207
|
+
paint['circle-stroke-opacity'].push(1)
|
|
208
|
+
paint['circle-stroke-width'].push(_defaultOutline.width)
|
|
209
|
+
return paint
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 获取圆符号聚类的layout样式
|
|
214
|
+
* @param {ClusterRenderer} renderer 聚类渲染器对象
|
|
215
|
+
* @return {Object} paint mapbox的圆形聚类的layout样式
|
|
216
|
+
* */
|
|
217
|
+
function getSymbolLayout(renderer) {
|
|
218
|
+
// 获取聚类参数
|
|
219
|
+
const clusterInfos = renderer.clusterInfos
|
|
220
|
+
// 获取默认文字符号
|
|
221
|
+
const _defaultLabelSymbol = renderer.defaultLabelSymbol
|
|
222
|
+
// 获取字体
|
|
223
|
+
let _fontFamily = '宋体'
|
|
224
|
+
// 找到第一个含有字体的符号
|
|
225
|
+
for (let i = 0; i < clusterInfos.length; i++) {
|
|
226
|
+
// 获取文字符号
|
|
227
|
+
const _labelSymbol = Symbol.fromJSON(clusterInfos[i].labelSymbol)
|
|
228
|
+
if (_labelSymbol && _labelSymbol.font && _labelSymbol.font.family) {
|
|
229
|
+
_fontFamily = _labelSymbol.font.family
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// 如果没有,则在默认文字符号中查找
|
|
233
|
+
if (
|
|
234
|
+
!_fontFamily &&
|
|
235
|
+
_defaultLabelSymbol &&
|
|
236
|
+
_defaultLabelSymbol.font &&
|
|
237
|
+
_defaultLabelSymbol.font.family
|
|
238
|
+
) {
|
|
239
|
+
_fontFamily = _defaultLabelSymbol.font.family
|
|
240
|
+
}
|
|
241
|
+
const layout = {
|
|
242
|
+
// 显示字段名,先固定后面再说
|
|
243
|
+
'text-field': '{point_count}',
|
|
244
|
+
// 字体,先固定后面再说
|
|
245
|
+
'text-font': [_fontFamily, _fontFamily],
|
|
246
|
+
// 设置字体大小
|
|
247
|
+
'text-size': ['step', ['get', 'point_count']]
|
|
248
|
+
}
|
|
249
|
+
for (let i = 0; i < clusterInfos.length; i++) {
|
|
250
|
+
// 获取文字符号
|
|
251
|
+
const _labelSymbol = Symbol.fromJSON(clusterInfos[i].labelSymbol)
|
|
252
|
+
// 设置字体大小
|
|
253
|
+
layout['text-size'].push(_labelSymbol.font.size)
|
|
254
|
+
layout['text-size'].push(clusterInfos[i].maxValue)
|
|
255
|
+
}
|
|
256
|
+
// 下面这些是必填项
|
|
257
|
+
// 超出最大数值时的字体大小
|
|
258
|
+
let _extraTextSize = 30
|
|
259
|
+
if (
|
|
260
|
+
_defaultLabelSymbol &&
|
|
261
|
+
_defaultLabelSymbol.font &&
|
|
262
|
+
_defaultLabelSymbol.font.size
|
|
263
|
+
) {
|
|
264
|
+
_extraTextSize = _defaultLabelSymbol.font.size
|
|
265
|
+
}
|
|
266
|
+
layout['text-size'].push(_extraTextSize)
|
|
267
|
+
return layout
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 获取圆符号聚类的paint样式
|
|
272
|
+
* @param {ClusterRenderer} renderer 聚类渲染器对象
|
|
273
|
+
* @param {Object} options 额外参数
|
|
274
|
+
* @param {Number} [options.opacity = 1] 图层透明度
|
|
275
|
+
* @return {Object} paint mapbox的圆形聚类的paint样式
|
|
276
|
+
* */
|
|
277
|
+
function getSymbolPaint(renderer, options) {
|
|
278
|
+
options = defaultValue(options, {})
|
|
279
|
+
// 图层透明度
|
|
280
|
+
options.opacity = defaultValue(options.opacity, 1)
|
|
281
|
+
// 获取聚类参数
|
|
282
|
+
const clusterInfos = renderer.clusterInfos
|
|
283
|
+
const paint = {
|
|
284
|
+
// 文字透明度
|
|
285
|
+
'text-opacity': 1
|
|
286
|
+
}
|
|
287
|
+
for (let i = 0; i < clusterInfos.length; i++) {
|
|
288
|
+
// 获取文字符号
|
|
289
|
+
const _labelSymbol = Symbol.fromJSON(clusterInfos[i].labelSymbol)
|
|
290
|
+
// 图层透明度*符号透明度,才是最终的透明度
|
|
291
|
+
paint['text-opacity'] = _labelSymbol.color.alpha * options.opacity
|
|
292
|
+
}
|
|
293
|
+
return paint
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 获取不在聚类范围内的圆形paint样式
|
|
298
|
+
* @param {ClusterRenderer} renderer 聚类渲染器对象
|
|
299
|
+
* @param {Object} options 额外参数
|
|
300
|
+
* @param {Number} [options.opacity = 1] 图层透明度
|
|
301
|
+
* @return {Object} paint 不在聚类范围内的圆形paint样式
|
|
302
|
+
* */
|
|
303
|
+
function getUnClusterCirclePaint(renderer, options) {
|
|
304
|
+
options = defaultValue(options, {})
|
|
305
|
+
// 图层透明度
|
|
306
|
+
options.opacity = defaultValue(options.opacity, 1)
|
|
307
|
+
// 拷贝颜色和外边线参数
|
|
308
|
+
const _defaultSymbol = renderer.defaultSymbol
|
|
309
|
+
const _defaultColor = Color.fromColor(_defaultSymbol.color)
|
|
310
|
+
const _defaultOutline = Symbol.fromJSON(_defaultSymbol.outline)
|
|
311
|
+
const _defaultOutlineColor = Color.fromColor(_defaultOutline.color)
|
|
312
|
+
return {
|
|
313
|
+
// 图层透明度*符号透明度,才是最终的透明度
|
|
314
|
+
'circle-opacity': _defaultColor.alpha * options.opacity,
|
|
315
|
+
// 不支持在颜色属性上设置透明度
|
|
316
|
+
'circle-color': _defaultColor.toCssRGBAString(),
|
|
317
|
+
'circle-radius': _defaultSymbol.size,
|
|
318
|
+
'circle-stroke-width': _defaultOutline.width,
|
|
319
|
+
// 不支持在颜色属性上设置透明度
|
|
320
|
+
'circle-stroke-color': _defaultOutlineColor.toCssRGBAString(),
|
|
321
|
+
// 图层透明度*符号透明度,才是最终的透明度
|
|
322
|
+
'circle-stroke-opacity': _defaultOutlineColor.alpha * options.opacity
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* 通过随机准提图和要素集合,构造一个单值专题图,注意随机专题图必须指定字段名,不指定则寻找字段名为oid的字段,没找到,则默认用属性里面的第一个字段名
|
|
328
|
+
* @param {RandomRenderer} randomRenderer 随即专题图
|
|
329
|
+
* @param {FeatureSet} featureSet 要素集合
|
|
330
|
+
* @return {UniqueValueRenderer} 单值专题图
|
|
331
|
+
* */
|
|
332
|
+
function getUniqueRendererFromRandomRenderer(randomRenderer, featureSet) {
|
|
333
|
+
// 获取要素数组
|
|
334
|
+
const _features = featureSet.features
|
|
335
|
+
// MapBox做专题图必须要字段名
|
|
336
|
+
let _field = randomRenderer.field
|
|
337
|
+
// 没找到字段名
|
|
338
|
+
if (!_field) {
|
|
339
|
+
// 获取要素里的所有字段名数组
|
|
340
|
+
const _keys = Object.keys(_features[0].attributes)
|
|
341
|
+
// 查看有没有oid字段名
|
|
342
|
+
for (let i = 0; i < _keys.length; i++) {
|
|
343
|
+
if (_keys[i].toLowerCase() === 'oid') {
|
|
344
|
+
_field = _keys[i]
|
|
345
|
+
break
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// 没有oid字段名,则用找到的第一个
|
|
349
|
+
_field = _keys[0]
|
|
350
|
+
}
|
|
351
|
+
// 构造单值专题图渲染器
|
|
352
|
+
const _uniqueValueInfos = []
|
|
353
|
+
for (let i = 0; i < _features.length; i++) {
|
|
354
|
+
let _uniqueValueInfo
|
|
355
|
+
switch (_features[i].geometry.type) {
|
|
356
|
+
case GeometryType.polygon:
|
|
357
|
+
case GeometryType.multiPolygon:
|
|
358
|
+
case GeometryType.extent:
|
|
359
|
+
case GeometryType.circle:
|
|
360
|
+
default:
|
|
361
|
+
_uniqueValueInfo = {
|
|
362
|
+
value: _features[i].attributes[_field],
|
|
363
|
+
symbol: new SimpleFillSymbol({
|
|
364
|
+
color: new Color(
|
|
365
|
+
parseInt(Math.random() * 255),
|
|
366
|
+
parseInt(Math.random() * 255),
|
|
367
|
+
parseInt(Math.random() * 255),
|
|
368
|
+
1
|
|
369
|
+
)
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
break
|
|
373
|
+
case GeometryType.lineString:
|
|
374
|
+
case GeometryType.multiLineString:
|
|
375
|
+
_uniqueValueInfo = {
|
|
376
|
+
value: _features[i].attributes[_field],
|
|
377
|
+
symbol: new SimpleLineSymbol({
|
|
378
|
+
color: new Color(
|
|
379
|
+
parseInt(Math.random() * 255),
|
|
380
|
+
parseInt(Math.random() * 255),
|
|
381
|
+
parseInt(Math.random() * 255),
|
|
382
|
+
1
|
|
383
|
+
),
|
|
384
|
+
width: 3
|
|
385
|
+
})
|
|
386
|
+
}
|
|
387
|
+
break
|
|
388
|
+
case GeometryType.point:
|
|
389
|
+
case GeometryType.multiPoint:
|
|
390
|
+
_uniqueValueInfo = {
|
|
391
|
+
value: _features[i].attributes[_field],
|
|
392
|
+
symbol: new SimpleMarkerSymbol({
|
|
393
|
+
color: new Color(
|
|
394
|
+
parseInt(Math.random() * 255),
|
|
395
|
+
parseInt(Math.random() * 255),
|
|
396
|
+
parseInt(Math.random() * 255),
|
|
397
|
+
1
|
|
398
|
+
)
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
break
|
|
402
|
+
}
|
|
403
|
+
_uniqueValueInfos.push(_uniqueValueInfo)
|
|
404
|
+
}
|
|
405
|
+
return new UniqueValueRenderer({
|
|
406
|
+
field: _field,
|
|
407
|
+
uniqueValueInfos: _uniqueValueInfos
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 获取圆形的等级符号绘制样式
|
|
413
|
+
* @param {Array<Feature>} features 要素数组
|
|
414
|
+
* @param {RankRenderer} renderer
|
|
415
|
+
* @param {Object} options 其他初始化参数
|
|
416
|
+
* @param {Number} [options.defaultSize = 20] 当未匹配到半径时的默认半径
|
|
417
|
+
* @return {Object} 绘制样式
|
|
418
|
+
* */
|
|
419
|
+
function getRankCircleStyle(features, renderer, options) {
|
|
420
|
+
options = defaultValue(options, {})
|
|
421
|
+
options.defaultSize = defaultValue(options.defaultSize, 20)
|
|
422
|
+
// 获取符号
|
|
423
|
+
const _symbol = renderer.symbol
|
|
424
|
+
// 获取默认符号
|
|
425
|
+
const _defaultSymbol = defaultValue(renderer.defaultSymbol, {})
|
|
426
|
+
// 默认半径大小
|
|
427
|
+
let _defaultSize = options.defaultSize
|
|
428
|
+
// 如果defaultSymbol设置了,则使用defaultSymbol设置的
|
|
429
|
+
if (_defaultSymbol && _defaultSymbol.size) {
|
|
430
|
+
_defaultSize = _defaultSymbol.size
|
|
431
|
+
}
|
|
432
|
+
// 外边线样式
|
|
433
|
+
const _outline = _symbol.outline
|
|
434
|
+
// mapbox的ATSL语法树说明
|
|
435
|
+
// [
|
|
436
|
+
// 注释: 写死为case
|
|
437
|
+
// 'case',
|
|
438
|
+
// 注释: ['get', 'name'] 表示获取字段名为name的数据,'==' 表示进行相等判断,'武昌区' 表示当值为武昌区时设置半径
|
|
439
|
+
// ['==', ['get', 'name'], '武昌区'],
|
|
440
|
+
// 注释: 当['==', ['get', 'name'], '武昌区']判断成立时, 设置半径大小为15
|
|
441
|
+
// 15,
|
|
442
|
+
// ['==', ['get', 'name'], '汉阳区'],
|
|
443
|
+
// 25,
|
|
444
|
+
// 注释: 当上述判断不成立时,使用的默认大小
|
|
445
|
+
// 20
|
|
446
|
+
// ]
|
|
447
|
+
// 设置半径的绘制样式
|
|
448
|
+
const circleRadiusATSL = ['case']
|
|
449
|
+
// 获取字段名
|
|
450
|
+
const _field = renderer.field
|
|
451
|
+
// 数据去重,如果相同字段值对应的半径不同,则取遇到的第一个
|
|
452
|
+
const _attributes = {}
|
|
453
|
+
for (let i = 0; i < features.length; i++) {
|
|
454
|
+
if (!_attributes.hasOwnProperty(features[i].attributes[_field])) {
|
|
455
|
+
_attributes[features[i].attributes[_field]] = features[i].symbol.size
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// 通过要素上的符号,生成ATSL语法树
|
|
459
|
+
Object.keys(_attributes).forEach(function (key) {
|
|
460
|
+
circleRadiusATSL.push(['==', ['get', _field], key])
|
|
461
|
+
circleRadiusATSL.push(_attributes[key])
|
|
462
|
+
})
|
|
463
|
+
// 当未匹配到半径时使用默认半径
|
|
464
|
+
circleRadiusATSL.push(_defaultSize)
|
|
465
|
+
// 返回圆形样式
|
|
466
|
+
return {
|
|
467
|
+
paint: {
|
|
468
|
+
// 设置圆形几何的填充颜色
|
|
469
|
+
'circle-color': _symbol.color.toCssRGBString(),
|
|
470
|
+
// 圆形几何的填充颜色的透明度
|
|
471
|
+
'circle-opacity': _symbol.color.alpha,
|
|
472
|
+
// 设置圆形几何的半径
|
|
473
|
+
'circle-radius': circleRadiusATSL,
|
|
474
|
+
// 设置外边线颜色
|
|
475
|
+
'circle-stroke-color': _outline.color.toCssRGBString(),
|
|
476
|
+
// 设置外边线透明度
|
|
477
|
+
'circle-stroke-opacity': _outline.color.alpha,
|
|
478
|
+
// 设置外边线宽度
|
|
479
|
+
'circle-stroke-width': _outline.width
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* 获取文字的等级符号绘制样式
|
|
486
|
+
* @param {Array<Feature>} features 要素数组
|
|
487
|
+
* @param {RankRenderer} renderer
|
|
488
|
+
* @param {Object} options 其他初始化参数
|
|
489
|
+
* @param {Number} [options.defaultSize = 20] 当未匹配到半径时的默认半径
|
|
490
|
+
* @param {Number} [options.fontFamily = '宋体'] 字体,需要mapbox中加载了该字体资源
|
|
491
|
+
* @return {Object} 绘制样式
|
|
492
|
+
* */
|
|
493
|
+
function getRankTextStyle(features, renderer, options) {
|
|
494
|
+
options = defaultValue(options, {})
|
|
495
|
+
options.defaultSize = defaultValue(options.defaultSize, 20)
|
|
496
|
+
options.fontFamily = defaultValue(options.fontFamily, '宋体')
|
|
497
|
+
// 获取字段名
|
|
498
|
+
const _field = renderer.field
|
|
499
|
+
// 获取符号
|
|
500
|
+
const _symbol = renderer.symbol
|
|
501
|
+
// 获取默认符号
|
|
502
|
+
const _defaultSymbol = defaultValue(renderer.defaultSymbol, {})
|
|
503
|
+
// 获取字体
|
|
504
|
+
let _fontFamily = options.fontFamily
|
|
505
|
+
const _font = _symbol.font
|
|
506
|
+
const _defaultFont = _defaultSymbol.font
|
|
507
|
+
if (_font && _font.family) {
|
|
508
|
+
_fontFamily = _font.family
|
|
509
|
+
} else if (_defaultFont && _defaultFont.family) {
|
|
510
|
+
_fontFamily = _defaultFont.family
|
|
511
|
+
}
|
|
512
|
+
// 默认字体大小
|
|
513
|
+
let _defaultSize = options.defaultSize
|
|
514
|
+
// 如果defaultSymbol设置了,则使用defaultSymbol设置的
|
|
515
|
+
if (_defaultSymbol && _defaultSymbol.size) {
|
|
516
|
+
_defaultSize = _defaultSymbol.size
|
|
517
|
+
}
|
|
518
|
+
// 数据去重,如果相同字段值对应的半径不同,则取遇到的第一个
|
|
519
|
+
const _attributes = {}
|
|
520
|
+
for (let i = 0; i < features.length; i++) {
|
|
521
|
+
if (!_attributes.hasOwnProperty(features[i].attributes[_field])) {
|
|
522
|
+
_attributes[features[i].attributes[_field]] = features[i].symbol.font.size
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
// 设置文字大小的绘制样式
|
|
526
|
+
// mapbox的ATSL语法树说明
|
|
527
|
+
// [
|
|
528
|
+
// 注释: 写死为case
|
|
529
|
+
// 'case',
|
|
530
|
+
// 注释: ['get', 'name'] 表示获取字段名为name的数据,'==' 表示进行相等判断,'武昌区' 表示当值为武昌区时设置半径
|
|
531
|
+
// ['==', ['get', 'name'], '武昌区'],
|
|
532
|
+
// 注释: 当['==', ['get', 'name'], '武昌区']判断成立时, 设置文字大小为15
|
|
533
|
+
// 15,
|
|
534
|
+
// ['==', ['get', 'name'], '汉阳区'],
|
|
535
|
+
// 25,
|
|
536
|
+
// 注释: 当上述判断不成立时,使用的默认大小
|
|
537
|
+
// 20
|
|
538
|
+
// ]
|
|
539
|
+
const textSizeATSL = ['case']
|
|
540
|
+
// 通过要素上的符号,生成ATSL语法树
|
|
541
|
+
Object.keys(_attributes).forEach(function (key) {
|
|
542
|
+
textSizeATSL.push(['==', ['get', _field], key])
|
|
543
|
+
textSizeATSL.push(_attributes[key])
|
|
544
|
+
})
|
|
545
|
+
// 当未匹配到半径时使用默认文字大小
|
|
546
|
+
textSizeATSL.push(_defaultSize)
|
|
547
|
+
// 获取文字颜色
|
|
548
|
+
let _color
|
|
549
|
+
if (_symbol && _symbol.color) {
|
|
550
|
+
_color = _symbol.color
|
|
551
|
+
} else if (_defaultSymbol && _defaultSymbol.color) {
|
|
552
|
+
_color = _symbol.color
|
|
553
|
+
} else {
|
|
554
|
+
_color = new Color(0, 0, 0, 1)
|
|
555
|
+
}
|
|
556
|
+
// 返回文字样式
|
|
557
|
+
return {
|
|
558
|
+
paint: {
|
|
559
|
+
// 文字颜色
|
|
560
|
+
'text-color': _color.toCssRGBString(),
|
|
561
|
+
// 文字透明度
|
|
562
|
+
'text-opacity': _color.alpha
|
|
563
|
+
},
|
|
564
|
+
layout: {
|
|
565
|
+
// 显示字段名,先固定后面再说
|
|
566
|
+
'text-field': _field,
|
|
567
|
+
// 字体,先固定后面再说
|
|
568
|
+
'text-font': [_fontFamily, _fontFamily],
|
|
569
|
+
// 设置字体大小
|
|
570
|
+
'text-size': textSizeATSL
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export {
|
|
576
|
+
getClusterCirclePaint,
|
|
577
|
+
getSymbolLayout,
|
|
578
|
+
getSymbolPaint,
|
|
579
|
+
getUnClusterCirclePaint,
|
|
580
|
+
getUniqueRendererFromRandomRenderer,
|
|
581
|
+
getRankCircleStyle,
|
|
582
|
+
getRankTextStyle
|
|
583
|
+
}
|
|
584
|
+
</code></pre>
|
|
585
|
+
</article>
|
|
586
|
+
</section>
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<footer class="footer">
|
|
594
|
+
<div class="content has-text-centered">
|
|
595
|
+
<p>文档生成<a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a></p>
|
|
596
|
+
<p class="sidebar-created-by">
|
|
597
|
+
<a href="http://www.smaryun.com" target="_blank">司马云</a> <span>© 2023 云生态圈</span>
|
|
598
|
+
<a href="http://192.168.82.89:8086/#/index" target="_blank">MapGIS Client for JavaScript</a>
|
|
599
|
+
</p>
|
|
600
|
+
</div>
|
|
601
|
+
</footer>
|
|
602
|
+
|
|
603
|
+
</div>
|
|
604
|
+
<div id="side-nav" class="side-nav">
|
|
605
|
+
<div style="margin-bottom: 10px;">
|
|
606
|
+
<img style="vertical-align: middle;margin-right: 10px;width: 30px;" src="./styles/anchor.png"/><a href="#page-title">构造函数</a>
|
|
607
|
+
</div>
|
|
608
|
+
<div style="margin-bottom: 10px;">
|
|
609
|
+
<img style="vertical-align: middle;margin-right: 10px;width: 30px;" src="./styles/anchor.png"/><a href="#member">成员变量</a>
|
|
610
|
+
</div>
|
|
611
|
+
<div style="margin-bottom: 10px;">
|
|
612
|
+
<img style="vertical-align: middle;margin-right: 10px;width: 30px;" src="./styles/anchor.png"/><a href="#function">方法</a>
|
|
613
|
+
</div>
|
|
614
|
+
<div>
|
|
615
|
+
<img style="vertical-align: middle;margin-right: 10px;width: 30px;" src="./styles/anchor.png"/><a href="#event">事件</a>
|
|
616
|
+
</div>
|
|
617
|
+
</div>
|
|
618
|
+
</div>
|
|
619
|
+
<script src="scripts/linenumber.js"> </script>
|
|
620
|
+
|
|
621
|
+
<script src="scripts/search.js"> </script>
|
|
622
|
+
|
|
623
|
+
</body>
|
|
624
|
+
</html>
|