Skip to content
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

Map tiles mostly disappear on zoom of standard map #69

Closed
chriszrc opened this issue Dec 25, 2018 · 8 comments
Closed

Map tiles mostly disappear on zoom of standard map #69

chriszrc opened this issue Dec 25, 2018 · 8 comments

Comments

@chriszrc
Copy link

chriszrc commented Dec 25, 2018

I can post all the code, but it's really just the standard setup of the basic map. I've never encountered this with other mapbox maps:

mapbox_weird

Appreciate any ideas of what might be going wrong. I can pan around on the initial zoom level and everything is fine, but as you can see in the recording, once I zoom in, the map gets weird-

@chriszrc
Copy link
Author

chriszrc commented Jan 3, 2019

I made some progress with this, seems that it's somehow related to vuex. I can use the map normally until I commit the map object to the vuex state. Then everything goes haywire, like in the video above. I've disabled everything that the app does with the map once it's in the state store. I can't for the life of me figure out why just adding the map object to the state store would cause this problem

@soal
Copy link
Owner

soal commented Jan 3, 2019

It's not that simple. It's generally bad idea to add to Vuex or component's data anything but primitive types and plain objects. Vue adds getters and setters to every property and it may break Map object (for example if getters/setters already used for some purpose).
If you want to store map object, store it as non-reactive in component or just add to $store object, like so:
in component:

export default {
  // …component code…
  created() {
    this.map = null
  },
  methods: {
   onMapLoaded(event) {
     // in component
     this.map = event.map
     // or just to store if you want have access from other components
     this.$store.map = event.map
   }
  }
}

@chriszrc
Copy link
Author

chriszrc commented Jan 3, 2019

Hi,

Thank you, yes, that explains it. I'm using typescript, so I can't just extend the $store in that way, but I created a shared service the store and components can share, and it works great. Closing-

@vinayakkulkarni
Copy link

@chriszrc Can you share a repro link? I'm facing a similar issue.

@chriszrc
Copy link
Author

chriszrc commented May 17, 2019 via email

@vinayakkulkarni
Copy link

vinayakkulkarni commented May 17, 2019

This issue was solved by not keeping the map object in a vuex store

I tried both options, still same issues if tiles aren't satellite

Ref: #111 (comment)

@crow7m
Copy link

crow7m commented Dec 8, 2019

In case this will help anyone, this solved my issues with multiple maps in one app, and their broken style:
geoMapLoaded(map) { let self = this; map._isVue = true; self.setEntityGeolocationMap(map); self.getEntityGeolocationMap.resize(); },

Actually setting isVue to true solved this map._isVue = true;

@thom4parisot
Copy link

thom4parisot commented Mar 23, 2020

Actually setting isVue to true solved this map._isVue = true;

It solved the issue on my side. My component has vuex-mapped properties, although this.map is not. But maybe vuex was messing with it anyway?

edit: actually, as stated in vuejs/vue#2637 (comment)

  1. If you need to skip observation for an object/array in data, use Object.freeze() on it;
  2. You don't need to put an object in data in order to access it on this. If you simply attach it to this in the created() hook, it doesn't get observed at all.

Declaring the property solely in the created() lifecycle method fixed the glitch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants