augustine-jkmap 1.1.0 → 1.1.2
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 +57 -0
- package/dist/augustine-jkmap.common.js +577 -544
- package/dist/augustine-jkmap.common.js.map +1 -1
- package/dist/augustine-jkmap.css +1 -1
- package/dist/augustine-jkmap.umd.js +577 -544
- package/dist/augustine-jkmap.umd.js.map +1 -1
- package/dist/augustine-jkmap.umd.min.js +1 -1
- package/dist/augustine-jkmap.umd.min.js.map +1 -1
- package/package.json +3 -2
- package/src/README.md +46 -0
- package/src/utils/index.js +16 -1
- package/src/utils/loadLayers.js +153 -0
- package/src/utils/index copy 2.js +0 -303
- package/src/utils/index copy.js +0 -1045
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "augustine-jkmap",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A Vue 2 component library",
|
|
5
5
|
"main": "dist/augustine-jkmap.common.js",
|
|
6
6
|
"unpkg": "dist/augustine-jkmap.umd.min.js",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "vue-cli-service build --target lib --name augustine-jkmap src/index.js",
|
|
37
|
-
"prepare": "npm run build"
|
|
37
|
+
"prepare": "npm run build",
|
|
38
|
+
"upgrade": "npm version patch && npm run build && npm publish --//registry.npmjs.org/:_authToken=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"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"vue": "^2.6.0 || ^2.7.0"
|
package/src/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# augustine_xumap
|
|
2
|
+
|
|
3
|
+
A Vue 2 & 3 compatible component library.
|
|
4
|
+
|
|
5
|
+
## 发布代码
|
|
6
|
+
ls lib/ # 看是否有 JS 文件
|
|
7
|
+
npm pack --dry-run # 看是否包含 lib/ 内容
|
|
8
|
+
# 删除命令(谨慎使用)
|
|
9
|
+
npm unpublish augustine_xumap@0.0.1
|
|
10
|
+
npm publish --//registry.npmjs.org/:_authToken=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
|
|
11
|
+
|
|
12
|
+
npm version patch # 0.0.1 → 0.0.2
|
|
13
|
+
npm version minor # 0.0.1 → 0.1.0
|
|
14
|
+
npm version major # 0.0.1 → 1.0.0
|
|
15
|
+
|
|
16
|
+
# 1. 升级版本(比如升补丁版)
|
|
17
|
+
npm version patch
|
|
18
|
+
|
|
19
|
+
# 输出:v0.0.2
|
|
20
|
+
|
|
21
|
+
# 2. 构建(确保 lib/ 是最新的)
|
|
22
|
+
npm run build
|
|
23
|
+
|
|
24
|
+
# 3. 发布新版本
|
|
25
|
+
npm publish
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install augustine_xumap
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Vue 3 (Vite)
|
|
36
|
+
import "augustine_xumap/lib/style.css";
|
|
37
|
+
import * as augustineXuMap from "augustine_xumap";
|
|
38
|
+
const { mapList } = augustineXuMap;
|
|
39
|
+
import { mapJump } from "augustine_xumap/utils/toArcGISPoint";
|
|
40
|
+
|
|
41
|
+
## Supports
|
|
42
|
+
- ✅ Vue 2.6+ and Vue 3
|
|
43
|
+
- ✅ Vite & Webpack
|
|
44
|
+
- ✅ Source Map debugging
|
|
45
|
+
- ✅ Tree-shaking
|
|
46
|
+
- ✅ Auto-import via `unplugin-vue-components`
|
package/src/utils/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/* eslint-disable require-jsdoc */
|
|
2
|
-
import { loadWmsLayer } from '
|
|
2
|
+
import { loadWmsLayer } from './loadLayers.js'
|
|
3
3
|
import { toArcGISPoint } from '../config/toArcGISPoint.js'
|
|
4
|
+
import {
|
|
5
|
+
arcGISTranformGeoJson,
|
|
6
|
+
geoJsonTranformArcgis,
|
|
7
|
+
geoJsonTranformWkt,
|
|
8
|
+
wktTranformGeoJson,
|
|
9
|
+
wktTranformArcgis,
|
|
10
|
+
arcgisTranformWkt
|
|
11
|
+
} from '../config/wktMethods.js'
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* 加载2D地图
|
|
6
15
|
* @param String mapId 地图容器id
|
|
@@ -1730,6 +1739,12 @@ async function createMaskLayer(polygonDataList = [], options, context = null, ma
|
|
|
1730
1739
|
}
|
|
1731
1740
|
}
|
|
1732
1741
|
export {
|
|
1742
|
+
arcGISTranformGeoJson,
|
|
1743
|
+
geoJsonTranformArcgis,
|
|
1744
|
+
geoJsonTranformWkt,
|
|
1745
|
+
wktTranformGeoJson,
|
|
1746
|
+
wktTranformArcgis,
|
|
1747
|
+
arcgisTranformWkt,
|
|
1733
1748
|
initMapPack,
|
|
1734
1749
|
createBase,
|
|
1735
1750
|
createMapView,
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 返回roles
|
|
3
|
+
* @param {*} maxLevel
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export function returnRole(maxLevel = 18, type = '2d') {
|
|
7
|
+
const lods = [],
|
|
8
|
+
isWebMercator = false
|
|
9
|
+
if (isWebMercator) {
|
|
10
|
+
// EPSG:3857(Web墨卡托)的LODs(单位:米/像素)
|
|
11
|
+
// 级别从0开始(行业惯例),分辨率逐级减半
|
|
12
|
+
const startResolution = 156543.03390625 // level 0的分辨率(米/像素)
|
|
13
|
+
const startScale = 591657527.591555 // level 0的比例尺(1:591657527.591555)
|
|
14
|
+
for (let level = 0; level <= maxLevel; level++) {
|
|
15
|
+
const levelValue = type == '2d' ? level : level + 1
|
|
16
|
+
// 0-20级(共21级)
|
|
17
|
+
lods.push({
|
|
18
|
+
level: level,
|
|
19
|
+
levelValue,
|
|
20
|
+
resolution: startResolution / Math.pow(2, level), // 逐级减半
|
|
21
|
+
scale: startScale / Math.pow(2, level)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
// EPSG:4490/4326(地理坐标系)的LODs(单位:度/像素)
|
|
26
|
+
// 级别从1开始(保持原逻辑兼容)
|
|
27
|
+
const startResolution = 0.703125 // level 1的分辨率(度/像素)
|
|
28
|
+
const startScale = 295497593.05875003 // level 1的比例尺
|
|
29
|
+
for (let level = 1; level <= maxLevel; level++) {
|
|
30
|
+
// 1-20级(共20级)
|
|
31
|
+
const levelValue = type == '2d' ? level - 1 : level
|
|
32
|
+
lods.push({
|
|
33
|
+
level: level - 1,
|
|
34
|
+
levelValue,
|
|
35
|
+
resolution: startResolution / Math.pow(2, level - 1), // 逐级减半(level 2是level 1的1/2)
|
|
36
|
+
scale: startScale / Math.pow(2, level - 1)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return lods
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 加载
|
|
44
|
+
* @param {*} options-传参
|
|
45
|
+
* @param {*} url 服务地址
|
|
46
|
+
* @param {*} subDomains 当瓦片服务器支持跨多个子域名请求以提高性能时使用。提供一个子域名数组
|
|
47
|
+
* @param {*} title 服务标题
|
|
48
|
+
* @param {*} id 为图层指定一个唯一的标识符
|
|
49
|
+
* @param {*} tileInfo 图层的名称或标题,通常用于图例或图层列表中展示
|
|
50
|
+
* @param {*} wkid 服务地图层级
|
|
51
|
+
* @param {*} fullExtent 服务地图层级
|
|
52
|
+
* @param {*} loadInfo 是否加载titleInfo
|
|
53
|
+
* @param {*} visible 布尔值,决定图层是否可见,默认是 true。设置为 false 可隐藏图层
|
|
54
|
+
* @param {*} opacity 图层的透明度,范围从0到1,默认是 1(完全不透明
|
|
55
|
+
* @param {*} minScale | maxScale 分别定义了图层的最大和最小比例尺。超出这些范围的缩放级别,图层将不会显示
|
|
56
|
+
* @param {*} popupTemplate 定义了点击图层上的要素时弹出窗口的内容模板
|
|
57
|
+
* @param {*} copyright 版权信息字符串,用于声明数据来源或版权声明
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export function loadWmsLayer(options) {
|
|
61
|
+
if (!options) return ''
|
|
62
|
+
let {
|
|
63
|
+
url,
|
|
64
|
+
subDomains,
|
|
65
|
+
title,
|
|
66
|
+
id,
|
|
67
|
+
tileInfo,
|
|
68
|
+
wkid,
|
|
69
|
+
fullExtent,
|
|
70
|
+
loadInfo = false,
|
|
71
|
+
visible = true,
|
|
72
|
+
opacity = 1,
|
|
73
|
+
minScale = 1,
|
|
74
|
+
maxScale = 22,
|
|
75
|
+
popupTemplate,
|
|
76
|
+
copyright = 'jk'
|
|
77
|
+
} = options
|
|
78
|
+
|
|
79
|
+
if (!url) return ''
|
|
80
|
+
|
|
81
|
+
const isVisible = visible || false
|
|
82
|
+
isVisible
|
|
83
|
+
minScale
|
|
84
|
+
maxScale
|
|
85
|
+
copyright
|
|
86
|
+
let params = {
|
|
87
|
+
visible: isVisible,
|
|
88
|
+
opacity,
|
|
89
|
+
|
|
90
|
+
spatialReference: {
|
|
91
|
+
wkid: 4490
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (subDomains) params.subDomains = subDomains
|
|
95
|
+
if (title) params.title = title
|
|
96
|
+
if (id) params.id = id
|
|
97
|
+
if (tileInfo) params.tileInfo = tileInfo
|
|
98
|
+
if (loadInfo) {
|
|
99
|
+
if (tileInfo) params.tileInfo = tileInfo
|
|
100
|
+
else if (window.jkEsri && window.jkEsri.TileInfo)
|
|
101
|
+
params.tileInfo = new window.jkEsri.TileInfo({
|
|
102
|
+
dpi: '90.71428571427429',
|
|
103
|
+
rows: 256,
|
|
104
|
+
cols: 256,
|
|
105
|
+
compressionQuality: 0,
|
|
106
|
+
origin: {
|
|
107
|
+
x: -180,
|
|
108
|
+
y: 90
|
|
109
|
+
},
|
|
110
|
+
spatialReference: {
|
|
111
|
+
wkid: 4490
|
|
112
|
+
},
|
|
113
|
+
lods: returnRole(28, '3d')
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
if (wkid) params.spatialReference.wkid = wkid
|
|
117
|
+
if (fullExtent) params.fullExtent = fullExtent
|
|
118
|
+
if (popupTemplate) params.popupTemplate = popupTemplate
|
|
119
|
+
return new window.jkEsri.WebTileLayer(url, params)
|
|
120
|
+
|
|
121
|
+
return layer
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 加载wmts服务
|
|
125
|
+
* @param Object options = {url,id,title} 参数
|
|
126
|
+
*/
|
|
127
|
+
export function WMTSlayer(options) {
|
|
128
|
+
let tileInfo = new window.jkEsri.TileInfo({
|
|
129
|
+
dpi: 90,
|
|
130
|
+
rows: 256,
|
|
131
|
+
cols: 256,
|
|
132
|
+
compressionQuality: 0,
|
|
133
|
+
origin: {
|
|
134
|
+
x: -180,
|
|
135
|
+
y: 90
|
|
136
|
+
},
|
|
137
|
+
spatialReference: {
|
|
138
|
+
wkid: 4490
|
|
139
|
+
},
|
|
140
|
+
lods: returnRole(25)
|
|
141
|
+
})
|
|
142
|
+
const url = `${options.url}?layers=jk_map_server%3Atgzx&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=${options.id}&STYLE=&TILEMATRIX=EPSG:4490:{z}&TILEMATRIXSET=EPSG:4490&FORMAT=image%2Fpng&TILECOL={x}&TILEROW={y}&key=586f4e24c298419e9d76302147f98cca`
|
|
143
|
+
const layer = new window.jkEsri.WebTileLayer({
|
|
144
|
+
urlTemplate: url,
|
|
145
|
+
id: options.id,
|
|
146
|
+
title: options.title,
|
|
147
|
+
tileInfo: tileInfo,
|
|
148
|
+
spatialReference: {
|
|
149
|
+
wkid: 4490
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
return layer
|
|
153
|
+
}
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
/* eslint-disable require-jsdoc */
|
|
2
|
-
import { loadWmsLayer } from '../config/loadLayers.js'
|
|
3
|
-
import { toArcGISPoint, mapJump } from '../config/toArcGISPoint.js'
|
|
4
|
-
import {
|
|
5
|
-
getTextSymbol,
|
|
6
|
-
getSimpleMarkerSymbol,
|
|
7
|
-
getPictureSymbol,
|
|
8
|
-
getLineSymbol,
|
|
9
|
-
getFillSymbol,
|
|
10
|
-
drawArcPoint,
|
|
11
|
-
createArcPoint,
|
|
12
|
-
createLineGraphicsLayer,
|
|
13
|
-
createMaskLayer,
|
|
14
|
-
createPolygonGraphicsLayer,
|
|
15
|
-
drawLayer
|
|
16
|
-
} from '../config/drawLayer.js'
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 加载2D地图
|
|
20
|
-
* @param String mapId 地图容器id
|
|
21
|
-
* @param Object params 地图参数
|
|
22
|
-
* @return Promise
|
|
23
|
-
*/
|
|
24
|
-
var arcgisCoreView = null,
|
|
25
|
-
arcgisCoreMap = null
|
|
26
|
-
/**
|
|
27
|
-
* 返回地图容器
|
|
28
|
-
* @param {*} data
|
|
29
|
-
*/
|
|
30
|
-
export function initMapPack(data) {
|
|
31
|
-
if (!arcgisCoreView && data.view) arcgisCoreView = data.view
|
|
32
|
-
if (!arcgisCoreMap && data.map) arcgisCoreMap = data.map
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 创建自定义底图
|
|
37
|
-
* @param {*} mapId
|
|
38
|
-
* @param {*} layer
|
|
39
|
-
* @param {*} params
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
export function createBase(mapId, layer, params) {
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
arcgisCoreMap = new window.jkEsri.Map({ layers: [layer] }) // 添加动态图层
|
|
45
|
-
const { minZoom = 6, maxZoom = 17 } = params
|
|
46
|
-
const viewOptions = {
|
|
47
|
-
container: mapId,
|
|
48
|
-
map: arcgisCoreMap,
|
|
49
|
-
ui: {
|
|
50
|
-
logo: false,
|
|
51
|
-
components: ['zoom']
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
Object.assign(viewOptions, params || {})
|
|
55
|
-
viewOptions.constraints = {
|
|
56
|
-
minZoom,
|
|
57
|
-
maxZoom
|
|
58
|
-
}
|
|
59
|
-
arcgisCoreView = new window.jkEsri.MapView(viewOptions)
|
|
60
|
-
arcgisCoreView.when(function () {
|
|
61
|
-
if (params.extent) {
|
|
62
|
-
goToViewExtent(params.extent)
|
|
63
|
-
}
|
|
64
|
-
resolve({ map: arcgisCoreMap, view: arcgisCoreView })
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 创建基础地图
|
|
70
|
-
* @param {*} mapId
|
|
71
|
-
* @param {*} params
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
export function createMapView(mapId, params) {
|
|
75
|
-
return new Promise((resolve) => {
|
|
76
|
-
/*天地图-影像(CGCS2000)*/
|
|
77
|
-
const layersType = params && params.layersType ? params.layersType : 'tdtYxt'
|
|
78
|
-
var tiandituDtLayer = loadWmsLayer({
|
|
79
|
-
id: layersType,
|
|
80
|
-
title: '天地图-影像',
|
|
81
|
-
url: 'http://{subDomain}.tianditu.gov.cn/img_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=img&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb',
|
|
82
|
-
subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
|
|
83
|
-
loadInfo: true
|
|
84
|
-
// fullExtent: {
|
|
85
|
-
// xmin: 109.613990783691,
|
|
86
|
-
// xmax: 117.323570251465,
|
|
87
|
-
// ymin: 20.131498336792,
|
|
88
|
-
// ymax: 25.5443782806396,
|
|
89
|
-
// spatialReference: 4490
|
|
90
|
-
// },
|
|
91
|
-
}),
|
|
92
|
-
tiandituDtBz = loadWmsLayer({
|
|
93
|
-
id: 'tiandituDtBz',
|
|
94
|
-
title: '天地图-影像注记',
|
|
95
|
-
url: 'http://{subDomain}.tianditu.gov.cn/cia_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cia&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb',
|
|
96
|
-
subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
|
|
97
|
-
loadInfo: true
|
|
98
|
-
// fullExtent: {
|
|
99
|
-
// xmin: 109.613990783691,
|
|
100
|
-
// xmax: 117.323570251465,
|
|
101
|
-
// ymin: 20.131498336792,
|
|
102
|
-
// ymax: 25.5443782806396,
|
|
103
|
-
// spatialReference: 4490
|
|
104
|
-
// }
|
|
105
|
-
})
|
|
106
|
-
if (layersType == 'tdtDxt') {
|
|
107
|
-
tiandituDtLayer = loadWmsLayer({
|
|
108
|
-
id: layersType,
|
|
109
|
-
title: '天地图-地形图',
|
|
110
|
-
url: 'http://{subDomain}.tianditu.gov.cn/ter_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=ter&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb',
|
|
111
|
-
subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
|
|
112
|
-
loadInfo: true
|
|
113
|
-
// fullExtent: {
|
|
114
|
-
// xmin: 109.613990783691,
|
|
115
|
-
// xmax: 117.323570251465,
|
|
116
|
-
// ymin: 20.131498336792,
|
|
117
|
-
// ymax: 25.5443782806396,
|
|
118
|
-
// spatialReference: 4490
|
|
119
|
-
// },
|
|
120
|
-
})
|
|
121
|
-
} else if (layersType == 'tdtSlt') {
|
|
122
|
-
tiandituDtLayer = loadWmsLayer({
|
|
123
|
-
id: 'tdtSlt',
|
|
124
|
-
title: '天地图-矢量图',
|
|
125
|
-
url: 'https://{subDomain}.tianditu.gov.cn/vec_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=vec&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}&tk=4267820f43926eaf808d61dc07269beb',
|
|
126
|
-
subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
|
|
127
|
-
loadInfo: true
|
|
128
|
-
// fullExtent: {
|
|
129
|
-
// xmin: 109.613990783691,
|
|
130
|
-
// xmax: 117.323570251465,
|
|
131
|
-
// ymin: 20.131498336792,
|
|
132
|
-
// ymax: 25.5443782806396,
|
|
133
|
-
// spatialReference: 4490
|
|
134
|
-
// },
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
arcgisCoreMap = new window.jkEsri.Map()
|
|
138
|
-
arcgisCoreMap.layers.add(tiandituDtLayer, 0)
|
|
139
|
-
|
|
140
|
-
arcgisCoreMap.layers.add(tiandituDtBz, 1)
|
|
141
|
-
const { minZoom = 6, maxZoom = 17 } = params
|
|
142
|
-
const param = {
|
|
143
|
-
map: arcgisCoreMap,
|
|
144
|
-
container: mapId
|
|
145
|
-
}
|
|
146
|
-
if (params && params.mapType && params.mapType == '3d') {
|
|
147
|
-
arcgisCoreView = new window.jkEsri.SceneView(param)
|
|
148
|
-
// arcgisCoreView.watch('zoom', (newZoom) => {
|
|
149
|
-
// if (newZoom < minZoom || newZoom > maxZoom) {
|
|
150
|
-
// arcgisCoreView.goTo(
|
|
151
|
-
// { zoom: Math.min(maxZoom, Math.max(minZoom, newZoom)) },
|
|
152
|
-
// { animate: false } // 禁用动画,避免闪烁
|
|
153
|
-
// )
|
|
154
|
-
// }
|
|
155
|
-
// })
|
|
156
|
-
} else {
|
|
157
|
-
Object.assign(param, params || {})
|
|
158
|
-
param.constraints = {
|
|
159
|
-
minZoom,
|
|
160
|
-
maxZoom
|
|
161
|
-
}
|
|
162
|
-
arcgisCoreView = new window.jkEsri.MapView(param)
|
|
163
|
-
}
|
|
164
|
-
arcgisCoreView.when(function () {
|
|
165
|
-
if (param.extent) {
|
|
166
|
-
goToViewExtent(param.extent)
|
|
167
|
-
}
|
|
168
|
-
resolve({ map: arcgisCoreMap, view: arcgisCoreView })
|
|
169
|
-
})
|
|
170
|
-
})
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* 跳转点
|
|
174
|
-
* @param String mapId 地图容器id
|
|
175
|
-
* @param Object params 地图参数
|
|
176
|
-
* @return Promise
|
|
177
|
-
*/
|
|
178
|
-
export function goToPoint(point, zoom = 17) {
|
|
179
|
-
arcgisCoreView.goTo(
|
|
180
|
-
{
|
|
181
|
-
target: toArcGISPoint(point), // 跳转目标点
|
|
182
|
-
tilt: 60, // 可选,目标视角倾斜角度
|
|
183
|
-
heading: 30, // 可选,目标视角方向角度
|
|
184
|
-
zoom // 可选,目标视角缩放级别
|
|
185
|
-
},
|
|
186
|
-
{ duration: 1000 }
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* 跳转extent
|
|
191
|
-
* @param Object extent 地图参数
|
|
192
|
-
*/
|
|
193
|
-
function goToViewExtent(extent) {
|
|
194
|
-
if (extent.xmin && extent.ymin && extent.xmax && extent.ymax) {
|
|
195
|
-
let wkid = extent.xmin > 1000 ? 102100 : 4326
|
|
196
|
-
arcgisCoreView.goTo(
|
|
197
|
-
new window.jkEsri.Extent(
|
|
198
|
-
extent.xmin,
|
|
199
|
-
extent.ymin,
|
|
200
|
-
extent.xmax,
|
|
201
|
-
extent.ymax,
|
|
202
|
-
new window.jkEsri.SpatialReference({
|
|
203
|
-
wkid: wkid
|
|
204
|
-
})
|
|
205
|
-
),
|
|
206
|
-
{ duration: 1000 }
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* 地图跳转
|
|
212
|
-
* @param {*} target
|
|
213
|
-
* @param {*} options
|
|
214
|
-
* @returns
|
|
215
|
-
*/
|
|
216
|
-
function goToMap(target, options = { zoom: 16 }) {
|
|
217
|
-
if (target && arcgisCoreView) {
|
|
218
|
-
if (
|
|
219
|
-
(target.x && target.y) ||
|
|
220
|
-
(target.longitude && target.latitude) ||
|
|
221
|
-
(target.jd && target.wd) ||
|
|
222
|
-
(target.length == 2 && target[0] && target[1]) ||
|
|
223
|
-
(target.lng && target.lat)
|
|
224
|
-
) {
|
|
225
|
-
goToPoint(target, options.zoom)
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
if (target.xmin && target.ymin && target.xmax && target.ymax) {
|
|
229
|
-
goToViewExtent(target)
|
|
230
|
-
return
|
|
231
|
-
}
|
|
232
|
-
mapJump(arcgisCoreView, target, options)
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* 获取面积
|
|
237
|
-
* @param geometry
|
|
238
|
-
*/
|
|
239
|
-
function getArea(geometry) {
|
|
240
|
-
const outSpatialReference = {
|
|
241
|
-
wkid: 4326
|
|
242
|
-
}
|
|
243
|
-
const newGeometry = window.jkEsri.projection.project(geometry, outSpatialReference)
|
|
244
|
-
// 平方米
|
|
245
|
-
return window.jkEsri.geometryEngine.geodesicArea(newGeometry, 'square-meters') //返回平方米
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* 绘制缓冲区
|
|
249
|
-
* @param {*} val
|
|
250
|
-
* @param {*} myDrawGeometry
|
|
251
|
-
* @returns
|
|
252
|
-
*/
|
|
253
|
-
function drawBuffer(val = 10, myDrawGeometry) {
|
|
254
|
-
return new Promise((resolve) => {
|
|
255
|
-
const outSpatialReference = {
|
|
256
|
-
wkid: 4326
|
|
257
|
-
}
|
|
258
|
-
const myDrawGeometryNew = window.jkEsri.projection.project(myDrawGeometry, outSpatialReference)
|
|
259
|
-
//公里-meters kilometers
|
|
260
|
-
const geometry = window.jkEsri.geometryEngine.geodesicBuffer(
|
|
261
|
-
myDrawGeometryNew,
|
|
262
|
-
val,
|
|
263
|
-
'kilometers'
|
|
264
|
-
)
|
|
265
|
-
let lineColor = new window.jkEsri.Color('red')
|
|
266
|
-
const color = new window.jkEsri.Color('red')
|
|
267
|
-
color.a = 0.1
|
|
268
|
-
const symbol = {
|
|
269
|
-
type: 'simple-fill',
|
|
270
|
-
color: color,
|
|
271
|
-
outline: {
|
|
272
|
-
color: lineColor,
|
|
273
|
-
width: 2,
|
|
274
|
-
style: 'solid'
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
let graphic = window.jkEsri.Graphic.fromJSON({
|
|
278
|
-
geometry,
|
|
279
|
-
attributes: null
|
|
280
|
-
})
|
|
281
|
-
graphic.symbol = symbol
|
|
282
|
-
resolve(graphic)
|
|
283
|
-
goToViewExtent(graphic.geometry.extent)
|
|
284
|
-
})
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export {
|
|
288
|
-
getArea,
|
|
289
|
-
goToMap,
|
|
290
|
-
drawBuffer,
|
|
291
|
-
getTextSymbol,
|
|
292
|
-
getSimpleMarkerSymbol,
|
|
293
|
-
getPictureSymbol,
|
|
294
|
-
getLineSymbol,
|
|
295
|
-
getFillSymbol,
|
|
296
|
-
toArcGISPoint,
|
|
297
|
-
drawArcPoint,
|
|
298
|
-
createArcPoint,
|
|
299
|
-
createLineGraphicsLayer,
|
|
300
|
-
createMaskLayer,
|
|
301
|
-
createPolygonGraphicsLayer,
|
|
302
|
-
drawLayer
|
|
303
|
-
}
|