-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoazafocus.js
98 lines (93 loc) · 2.6 KB
/
oazafocus.js
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
styles.oazafocus = {
getStyle: function() {
return 'https://vt-cm01.mapion.co.jp/gl-server/style/lab.json?increment=1&access_token=' + accessToken;
},
_init: false,
_popup: new mapboxgl.Popup({
closeButton: false,
closeOnClick: false
}),
onChangeSelect: function() {
if (!styles.oazafocus._init) {
map.on('mousemove', 'oaza-fills', function(e) {
if (e.features.length > 0) {
if (hoveredId) {
map.setFeatureState(
{ source: 'oaza', sourceLayer: 'oaza_polygon', id: hoveredId },
{ hover: false }
);
styles.oazafocus._popup.remove();
}
hoveredId = e.features[0].id;
map.setFeatureState(
{ source: 'oaza', sourceLayer: 'oaza_polygon', id: hoveredId },
{ hover: true }
);
var oazaName = e.features[0].properties.oaza_name;
if (oazaName) {
styles.oazafocus._popup
.setLngLat(e.lngLat)
.setHTML(e.features[0].properties.oaza_name)
.addTo(map);
}
}
});
map.on('mouseleave', 'oaza-fills', function() {
if (hoveredId) {
map.setFeatureState(
{ source: 'oaza', sourceLayer: 'oaza_polygon', id: hoveredId },
{ hover: false }
);
}
hoveredId = null;
styles.oazafocus._popup.remove();
});
}
},
onStyledata: function() {
var source = map.getSource('oaza');
if (!source) {
map.addSource('oaza', {
'type': 'vector',
'tiles': [
'https://vt-cm01-stg.mapion.co.jp/gl-server/tile/honjo.gyousei_polygon/{z}/{x}/{y}.pbf?access_token=' + accessToken
],
'minzoom': 10,
'maxzoom': 15
});
map.addLayer({
'id': 'oaza-fills',
'type': 'fill',
'source': 'oaza',
'source-layer': 'oaza_polygon',
'layout': {},
'paint': {
'fill-color': '#F85C5C',
'fill-opacity': [
'case',
['boolean', ['feature-state', 'hover'], false],
0.5,
0
]
}
}, 'city_rep_point 地番ポイント');
map.addLayer({
'id': 'oaza-borders',
'type': 'line',
'source': 'oaza',
'source-layer': 'oaza_polygon',
'layout': {},
'paint': {
'line-color': '#F85C5C',
'line-width': 2,
'line-opacity': [
'case',
['boolean', ['feature-state', 'hover'], false],
1,
0
]
}
});
}
}
}