-
Notifications
You must be signed in to change notification settings - Fork 0
/
3D建筑.html
112 lines (100 loc) · 3.5 KB
/
3D建筑.html
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
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>3d</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<link rel="stylesheet" href="css/mapbox-gl.css" type="text/css"/>
<script type="text/javascript" src="js/mapbox-gl.js"></script>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = new mapboxgl.Map({
container: 'map', // container id
style: { // stylesheet location
"version": 8,
"sources": {},
"layers": []
},
center: [118.7725,32.0509],
zoom: 10, // starting zoom
pitch: 40,
bearing: -20
});
map.on("load",function(){
var arcgis_wmts ='http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/WMTS?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ChinaOnlineCommunity&STYLE=default&TILEMATRIXSET=default028mm&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/png'
var arcgis_layer = {
"id": "arcgis_wmts",
"type": "raster",
"source": {
"type": "raster",
"tiles": [arcgis_wmts],
"zoomOffset": 0,//wmts Capabilities信息中TileMatrix第一个对应的实际多少级
"tileSize": 256
}
};
map.addLayer(arcgis_layer);
})
map.on("load", function() {
map.addSource("3d", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"level": 1,
"name": "Bird Exhibit",
"height": 5000,
"base_height": 0,
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[118.7739, 32.1212],
[118.7427, 32.1109],
[118.7258, 32.0811],
[118.7248, 32.0543],
[118.7008, 31.9942],
[118.6654, 31.9722],
[118.7176, 31.9520],
[118.7914 ,31.9709],
[118.8783, 32.0340],
[118.8834, 32.0962],
[118.8062, 32.1181],
]
]
}
}]
}
});
map.addLayer({
"id": "park-boundary",
"type": "fill-extrusion",
"source": "3d",
"paint": {
'fill-extrusion-color': '#FFA54F',
'fill-extrusion-height': ['get', 'height'],
'fill-extrusion-base': ['get', 'base_height'],
'fill-extrusion-opacity': 0.6
},
// "filter": ["==", "$type", "Polygon"]
});
map.on('mousemove',function(e){
var features=map.queryRenderedFeatures(e.point,{layers:['park-boundary']})
if(features.length>0){
map.setPaintProperty('park-boundary','fill-extrusion-color','#faafee')
}else{
map.setPaintProperty('park-boundary',"fill-extrusion-color" ,'#FFA54F')
}
})
});
</script>
</body>
</html>