-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathmapbox-large-waterways.vue
55 lines (49 loc) · 1.31 KB
/
mapbox-large-waterways.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
53
54
55
<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/waterways_china.geojson';
this.map.addSource('waterways', { type: 'geojson', data: url });
this.map.addLayer({
'id': 'waterways',
'type': 'line',
'source': 'waterways',
'paint': {
'line-color': 'DarkViolet',
'line-opacity': 0.6,
'line-width': .9
},
'layout': {
'line-cap': 'round',
}
});
this.map.addControl(new mapboxgl.NavigationControl());
}
}
</script>
<style scoped>
#map {
height: 100%;
}
</style>