33 <MglMap
44 ref =" theMap"
55 :accessToken =" accessToken"
6- :minZoom =" 1.4 "
6+ :minZoom =" 1"
77 :maxZoom =" 8"
88 class =" my-mapbox"
99 :mapStyle.sync =" mapStyle"
@@ -59,7 +59,7 @@ export default {
5959 props: {
6060 cities: {
6161 type: Array
62- },
62+ }
6363 },
6464 data () {
6565 return {
@@ -69,7 +69,7 @@ export default {
6969 mapStyle: process .env .VUE_APP_MAPBOX_STYLE , // your map style
7070 // theCenter: [-60.675328, -31.617428],
7171 // theCenter: [32, -15],
72- showCities: true ,
72+ showCities: true
7373 };
7474 },
7575 methods: {
@@ -109,46 +109,57 @@ export default {
109109 this .$refs .theMap .map .getCanvas ().style .cursor = " grab" ;
110110 },
111111 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 = " " ;
117124 } 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+ );
120131 }
121- this .toggleShowCities ()
132+ this .toggleShowCities ();
122133 },
123134 toggleShowCities : function () {
124135 this .showCities = ! this .showCities ;
125136 },
126137 drawCountryGeoJson : async function (geojson ) {
127- console .log (geojson)
138+ console .log (geojson);
128139 await this .$refs .theMap .map .addSource (" countries" , geojson);
129140 await this .$refs .theMap .map .addLayer ({
130141 id: " countries-layer" ,
131142 type: " fill" ,
132143 source: " countries" ,
133144 layout: {
134- " visibility" : " visible"
145+ visibility: " visible"
135146 },
136147 paint: {
137148 " fill-color" : " #da8313" ,
138- " fill-opacity" : 0.4 ,
149+ " fill-opacity" : 0.4
139150 }
140151 // "filter": ["==", "$type", "Polygon"]
141152 });
142- await this .$refs .theMap .map .on (' mouseenter' , ' countries-layer' , ( e ) => {
153+ await this .$refs .theMap .map .on (" mouseenter" , " countries-layer" , e => {
143154 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 ();
152163 // await this.$refs.theMap.map.addLayer({
153164 // id: "countries-labels",
154165 // type: "symbol",
@@ -169,9 +180,9 @@ export default {
169180 }
170181 },
171182 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 [];
175186 }
176187 }
177188};
0 commit comments