-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathmapbox-large-buildings.vue
52 lines (46 loc) · 1.28 KB
/
mapbox-large-buildings.vue
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
<template>
<div id="map"></div>
</template>
<script>
import mapboxgl from "mapbox-gl";
export default {
data() {
return {
map: null
}
},
mounted() {
this.map = new mapboxgl.Map({
container: 'map',
zoom: 1,
});
this.map.addSource('osm', {
type: 'raster',
tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', 'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png', 'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'],
tileSize: 256 });
this.map.addLayer({
id: 'osm',
type: 'raster',
source: 'osm'
});
let url = 'http://localhost:8000/buildings_china_taiwan.geojson';
this.map.addSource('buildings', { type: 'geojson', data: url });
this.map.addLayer({
'id': 'buildings',
'type': 'fill-extrusion',
'source': 'buildings',
'paint': {
'fill-extrusion-color': 'Crimson',
'fill-extrusion-height': 100,
'fill-extrusion-opacity': 0.9,
}
});
this.map.addControl(new mapboxgl.NavigationControl());
}
}
</script>
<style scoped>
#map {
height: 100%;
}
</style>