3
3
<MglMap
4
4
ref =" theMap"
5
5
:accessToken =" accessToken"
6
- :minZoom =" 1.4 "
6
+ :minZoom =" 1"
7
7
:maxZoom =" 8"
8
8
class =" my-mapbox"
9
9
:mapStyle.sync =" mapStyle"
@@ -59,7 +59,7 @@ export default {
59
59
props: {
60
60
cities: {
61
61
type: Array
62
- },
62
+ }
63
63
},
64
64
data () {
65
65
return {
@@ -69,7 +69,7 @@ export default {
69
69
mapStyle: process .env .VUE_APP_MAPBOX_STYLE , // your map style
70
70
// theCenter: [-60.675328, -31.617428],
71
71
// theCenter: [32, -15],
72
- showCities: true ,
72
+ showCities: true
73
73
};
74
74
},
75
75
methods: {
@@ -109,46 +109,57 @@ export default {
109
109
this .$refs .theMap .map .getCanvas ().style .cursor = " grab" ;
110
110
},
111
111
toggleCountriesVisibility : async function () {
112
- var visibility = await this .$refs .theMap .map .getLayoutProperty (' countries-layer' , ' visibility' );
113
-
114
- if (visibility === ' visible' ) {
115
- await this .$refs .theMap .map .setLayoutProperty (' countries-layer' , ' visibility' , ' none' );
116
- this .className = ' ' ;
112
+ var visibility = await this .$refs .theMap .map .getLayoutProperty (
113
+ " countries-layer" ,
114
+ " visibility"
115
+ );
116
+
117
+ if (visibility === " visible" ) {
118
+ await this .$refs .theMap .map .setLayoutProperty (
119
+ " countries-layer" ,
120
+ " visibility" ,
121
+ " none"
122
+ );
123
+ this .className = " " ;
117
124
} else {
118
- this .className = ' active' ;
119
- await this .$refs .theMap .map .setLayoutProperty (' countries-layer' , ' visibility' , ' visible' );
125
+ this .className = " active" ;
126
+ await this .$refs .theMap .map .setLayoutProperty (
127
+ " countries-layer" ,
128
+ " visibility" ,
129
+ " visible"
130
+ );
120
131
}
121
- this .toggleShowCities ()
132
+ this .toggleShowCities ();
122
133
},
123
134
toggleShowCities : function () {
124
135
this .showCities = ! this .showCities ;
125
136
},
126
137
drawCountryGeoJson : async function (geojson ) {
127
- console .log (geojson)
138
+ console .log (geojson);
128
139
await this .$refs .theMap .map .addSource (" countries" , geojson);
129
140
await this .$refs .theMap .map .addLayer ({
130
141
id: " countries-layer" ,
131
142
type: " fill" ,
132
143
source: " countries" ,
133
144
layout: {
134
- " visibility" : " visible"
145
+ visibility: " visible"
135
146
},
136
147
paint: {
137
148
" fill-color" : " #da8313" ,
138
- " fill-opacity" : 0.4 ,
149
+ " fill-opacity" : 0.4
139
150
}
140
151
// "filter": ["==", "$type", "Polygon"]
141
152
});
142
- await this .$refs .theMap .map .on (' mouseenter' , ' countries-layer' , ( e ) => {
153
+ await this .$refs .theMap .map .on (" mouseenter" , " countries-layer" , e => {
143
154
this .$refs .theMap .map .getCanvas ().style .cursor = " pointer" ;
144
- })
145
- await this .$refs .theMap .map .on (' mouseleave' , ' countries-layer' , ( e ) => {
146
- this .$refs .theMap .map .getCanvas ().style .cursor = ' ' ;
147
- })
148
- await this .$refs .theMap .map .on (' click' , ' countries-layer' , ( e ) => {
149
- this .openCountryModalLayer (e .features [0 ].properties )
150
- })
151
- this .toggleShowCities ()
155
+ });
156
+ await this .$refs .theMap .map .on (" mouseleave" , " countries-layer" , e => {
157
+ this .$refs .theMap .map .getCanvas ().style .cursor = " " ;
158
+ });
159
+ await this .$refs .theMap .map .on (" click" , " countries-layer" , e => {
160
+ this .openCountryModalLayer (e .features [0 ].properties );
161
+ });
162
+ this .toggleShowCities ();
152
163
// await this.$refs.theMap.map.addLayer({
153
164
// id: "countries-labels",
154
165
// type: "symbol",
@@ -169,9 +180,9 @@ export default {
169
180
}
170
181
},
171
182
computed: {
172
- citiesArray : function (){
173
- if (this .showCities ) return this .cities
174
- else return []
183
+ citiesArray : function () {
184
+ if (this .showCities ) return this .cities ;
185
+ else return [];
175
186
}
176
187
}
177
188
};
0 commit comments