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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
| import * as mars3d from "mars3d"
|
| export let map // mars3d.Map三维地图对象
|
| // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
| export const mapOptions = {
| scene: {
| center: { lat: 31.838348, lng: 117.206494, alt: 752, heading: 359, pitch: -54 }
| }
| }
|
| /**
| * 初始化地图业务,生命周期钩子函数(必须)
| * 框架在地图初始化完成后自动调用该函数
| * @param {mars3d.Map} mapInstance 地图对象
| * @returns {void} 无
| */
| export function onMounted(mapInstance) {
| map = mapInstance // 记录map
|
| // 三维模型【目前没有全合肥的模型,下面模型为了测试下】
| const tilesetLayer = new mars3d.layer.TilesetLayer({
| type: "3dtiles",
| name: "合肥国家大学科技园",
| url: "//data.mars3d.cn/3dtiles/qx-hfdxy/tileset.json",
| position: { alt: -24 },
| maximumScreenSpaceError: 1,
| maximumMemoryUsage: 1024,
| show: true
| })
| map.addLayer(tilesetLayer)
|
| map.on(mars3d.EventType.load, () => {
| addWfsLayer()
| })
| }
|
| /**
| * 释放当前地图业务的生命周期函数
| * @returns {void} 无
| */
| export function onUnmounted() {
| map = null
| }
|
| function addWfsLayer() {
| // 单体化图层【支持geoserver的wfs服务配置dth属性】
| const wfsLayer = new mars3d.layer.WfsLayer({
| name: "建筑物面",
| url: "//server.mars3d.cn/geoserver/mars/wfs",
| layer: "mars:hfjzw",
| parameters: {
| // 支持所有wfs的参数
| maxFeatures: 500
| },
| minimumLevel: 15,
| debuggerTileInfo: false,
| popup: "名称:{NAME}<br />层数:{floor}",
| symbol: {
| type: "polygonP",
| styleOptions: {
| // 单体化默认显示样式
| color: "rgba(255, 255, 255, 0.01)",
| clampToGround: true,
| classification: true,
| buffer: 2,
| // 单体化鼠标移入或单击后高亮的样式
| highlight: {
| // type: mars3d.EventType.click,
| color: "rgba(255,255,0,0.4)"
| }
| }
| },
| show: true
| })
| map.addLayer(wfsLayer)
|
| // 单体化图层【也支持arcgis的wfs服务配置dth属性】
| // let wfsLayer = new mars3d.layer.ArcGisWfsLayer({
| // name: "建筑物面矢量图层",
| // url: "//server.mars3d.cn/arcgis/rest/services/mars/hefei/MapServer/37",
| // minimumLevel: 15,
| // debuggerTileInfo: false,
| // popup: "名称:{NAME}<br />层数:{floor}",
| // symbol: {
| // type: "polygonP",
| // styleOptions: {
| // // 单体化默认显示样式
| // color: "rgba(255, 255, 255, 0.01)",
| // clampToGround: true,
| // classification: true,
| // // 单体化鼠标移入或单击后高亮的样式
| // highlight: {
| // // type: mars3d.EventType.click,
| // color: "rgba(255,255,0,0.4)"
| // }
| // }
| // }
| // })
| // map.addLayer(wfsLayer)
| }
|
|