question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-mapbox basemaps tiles get disappeared

See original GitHub issue

Here’s my data object:

data() {
    return {
      map: null,
      accessToken: null, // your access token. Needed if you using Mapbox maps
      mapStyle:`https://maps.tilehosting.com/styles/voyager/style.json?key={KEY}`, // your map style
    };
  },

When the map is zoomed, the tiles aren’t being fetched. Demo: https://bit.ly/soal-vue-mapbox

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
maximelebretoncommented, Jul 23, 2020

After hours spent on this problem, here is my working solution to access map instance from a store (thanks to https://github.com/vuejs/vue/issues/2637#issuecomment-207076744 and https://github.com/vuejs/vue/issues/2637#issuecomment-331913620):

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>

3reactions
danielholmescommented, Jun 26, 2019

@vinayakkulkarni My temporary solution was to access the map via refs. e.g.:

<mgl-map ref="mglMap" ... />
this.$refs.mglMap.map.fitBounds(...);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Blank or missing map tiles | Help - Mapbox docs
Learn why you may be seeing blank or missing tiles.
Read more >
tiles missing within bounding box in leaflet - Stack Overflow
But the problem is, some tiles are missing from the right side of the map when I am panning the base map as...
Read more >
Mapbox Natural earth map disappears on zooms 0 & 1
Vector tiles have different data at each zoom level. I'm guessing that the source vector tile dataset you're using in your style does...
Read more >
Unable to bring up any Base Map in PIX4DCapture
In some places, missing tiles may occur while using the map or satellite view depending on the zoom level. Unfortunately, only the base...
Read more >
TileLayer - deck.gl
This approach minimizes the visual flashing due to missing content. 'no-overlap' : Avoid showing overlapping tiles when backfilling with cached content. This is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found