-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-mapbox basemaps tiles get disappeared #111
Comments
bump |
🛎 |
I have the same issue. |
Anything in console? |
Nope. All clear Also, i tried using mapbox styles, as @ajotka said, only |
With Vuex: <template>
<MglMap
:access-token="accessToken"
:map-style.sync="mapStyle"
@load="onMapLoaded"
>
<MglNavigationControl position="bottom-right" />
<MglGeolocateControl position="top-right" />
<MglScaleControl position="bottom-left" />
</MglMap>
</template>
<script>
import {
MglMap,
MglNavigationControl,
MglGeolocateControl,
MglScaleControl,
} from 'vue-mapbox';
import { mapState } from 'vuex';
export default {
name: 'DashboardMap',
components: {
MglMap,
MglNavigationControl,
MglGeolocateControl,
MglScaleControl,
},
data() {
return {
accessToken: process.env.mapToken,
mapStyle: 'mapbox://styles/mapbox/satellite-streets-v9',
};
},
computed: {
...mapState('map', ['map']),
},
beforeDestroy() {
this.$store.commit('map/destroyMap');
},
methods: {
onMapLoaded(event) {
this.$store.commit('map/initializeMap', event.map);
},
},
};
</script> Without Vuex: <template>
<MglMap
:access-token="accessToken"
:map-style.sync="mapStyle"
@load="onMapLoaded"
>
<MglNavigationControl position="bottom-right" />
<MglGeolocateControl position="top-right" />
<MglScaleControl position="bottom-left" />
</MglMap>
</template>
<script>
import {
MglMap,
MglNavigationControl,
MglGeolocateControl,
MglScaleControl,
} from 'vue-mapbox';
export default {
name: 'DashboardMap',
components: {
MglMap,
MglNavigationControl,
MglGeolocateControl,
MglScaleControl,
},
data() {
return {
localMap: null,
accessToken: process.env.mapToken,
mapStyle: 'mapbox://styles/mapbox/satellite-streets-v9',
};
},
created() {
this.localMap = null;
},
beforeDestroy() {
this.localMap = null;
},
methods: {
onMapLoaded(event) {
this.localMap = event.map;
},
},
};
</script> |
bump |
Experienced the same issue |
Ok, after removing any and all |
This Stack Overflow question appears to be related: https://stackoverflow.com/questions/50824353/mapbox-style-changes-breaks-on-zoom-when-a-layer-is-added |
@vinayakkulkarni My temporary solution was to access the map via refs. e.g.: <mgl-map ref="mglMap" ... /> this.$refs.mglMap.map.fitBounds(...); |
After hours spent on this problem, here is my working solution to access map instance from a store (thanks to vuejs/vue#2637 (comment) and vuejs/vue#2637 (comment)): const state = reactive({
map: Object.freeze({ wrapper: /* PUT THE MAP INSTANCE HERE */ });
}); Here is an example with Vue Composition Api: index.js import { reactive, computed } from "@vue/composition-api";
export const state = reactive({
map: null
});
export const setMap = (map) => {
state.map = Object.freeze({ wrapper: map});
};
export const getMap = computed(() => state.map.wrapper);
export const initMap = (event) => {
setMap(event.map);
// now you can access to map instance from the "getMap" getter!
getMap.value.addSource("satellite-source", {
type: "raster",
url: "mapbox://mapbox.satellite",
});
getMap.value.addLayer({
id: "satellite-layer",
type: "raster",
source: "satellite-source"
});
}; App.vue <template>
<MglMap :accessToken="..." :mapStyle="..." @load="onMapLoaded" />
</template>
<script>
import { defineComponent } from "@vue/composition-api";
import { MglMap } from "vue-mapbox";
import { initMap } from "./index.js";
export default defineComponent({
components: {
MglMap
},
setup() {
const onMapLoaded = (event) => {
initMap(event);
}
return { onMapLoaded };
}
});
</script>
|
Here's my data object:
When the map is zoomed, the tiles aren't being fetched.
Demo: https://bit.ly/soal-vue-mapbox
The text was updated successfully, but these errors were encountered: