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

Working with Vuex Map #871

Open
liamb13 opened this issue Apr 12, 2022 · 3 comments
Open

Working with Vuex Map #871

liamb13 opened this issue Apr 12, 2022 · 3 comments

Comments

@liamb13
Copy link

liamb13 commented Apr 12, 2022

I know the docs briefly touch on setting the map to Vuex store;

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;
    }

https://v-mapbox.geospoc.io/guide/basemap.html#map-loading

However, they don't mention how to load a map from the store?
I'm assuming this is relatively easier and I'm likely overthinking it.

@joankuah
Copy link

joankuah commented Nov 7, 2022

Hello, I came across this issue and I'm also interested to know more on how we could use Vuex to store the event.map.
Based on the current docs it mentioned storing it to the state:

// or just to store if you want have access from other components
this.$store.map = event.map;

However, as far as I know, the only way to change a store's state is through committing mutations.

Would really appreciate if there are some examples that can be used as a reference or more information regarding this issue could be shown in the docs would be great.

@vinayakkulkarni
Copy link
Owner

vinayakkulkarni commented Mar 9, 2023

Preferable don't store large objects in store, I usually use the [markRaw()](https: //vuejs.org/api/reactivity-advanced.html#markraw
) to store the map variable locally like this

@joankuah
Copy link

joankuah commented Jun 6, 2023

Thanks for the advice @vinayakkulkarni. I wrapped my map instance with markRaw() and it worked without making it reactive. Something to take note from the docs, if I need to make it reactive, it will return a proxied version back.

For anyone that had the same issue as me 🤣 I'm using pinia instead of vuex:
https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-external-properties

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

No branches or pull requests

3 participants