将已发布的矢量切片图层添加至现有地图。
矢量切片图层是托管图层。数据源是矢量切片数据。通过数据管理工具发布。
在本教程中,将使用默认样式显示公共矢量切片服务中的宗地图层。
步骤
创建新 Pen
- 要开始使用,请完成显示地图教程 或 使用此 Pen。
添加模块
在 require
语句中,添加 VectorTileLayer
模块。
GeoScene Maps SDK for JavaScript 提供有 AMD 模块和 ES 模块,但本教程基于 AMD。AMD require
函数使用引用来确定加载哪些模块 - 例如,您可以指定 "geoscene/Map"
来加载 Map 模块。加载模块后,它们将作为参数 (例如,Map
) 传递给回调函数,以便在应用程序中使用。保持模块引用和回调参数的顺序相同是很重要的。有关不同类型模块的更多信息,请访问工具指南主题。
添加行。更改行1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require([
"geoscene/config",
"geoscene/Map",
"geoscene/layers/VectorTileLayer",
"geoscene/views/MapView"
], function (geosceneConfig, Map, VectorTileLayer, MapView) {
添加矢量切片图层
创建 VectorTileLayer
。设置 url
属性以引用矢量切片图层。
添加行。添加行。添加行。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
], function (geosceneConfig, Map, VectorTileLayer, MapView) {
const vtlLayer = new VectorTileLayer({
url: "https://vectortileservices3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_Mountains_Parcels_VTL/VectorTileServer/"
});
更新地图
将 layers
设置为 vtlLayer
元素。
更改行添加行。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const map = new Map({
basemap: "tianditu-vector",
layers: [vtlLayer]
});
运行应用程序
在 CodePen 中,运行代码以显示地图。
您应看到在底图图层上显示的宗地矢量切片图层。
要了解如何使用其他 API 功能,请参阅以下教程: