Vue2leaflet: setCenter called on child prop change?

Created on 4 May 2017  路  4Comments  路  Source: vue-leaflet/Vue2Leaflet

I have a simple Button component, which extends L.Control and receives a toggle prop:

<v-map ...>
  <v-btn :toggle="mode" v-on:toggleEvent="toggleMode"></v-btn>
</v-map>

A click on the control fires toggleEvent, which toggles mode between true and false -- nothing more.

I noticed that every time mode changes the map zooms and pans back into its initial position and zoom level. I checked the leaflet events without much luck, but just found out that I can avoid the problem by patching the setCenter method on my map with an empty function.

I'm not sure what exactly causes the call to setCenter in the first place and whether it's desired behaviour? Anyway to avoid this without removing the method?

Most helpful comment

This should be fixed in v0.0.49

All 4 comments

I'm just running into this problem now as well. I can't seem to find what's causing this either, although my case seems to be a bit different.

Whenever a v-bind:style update is occurring on another element (sibling) the map is automatically returning to defaults.

In this gist https://gist.github.com/xemoka/751a2f669685ccd1f17cc04a44c29f51 when line 6 is commented out, it doesn't occurr.

I'm not sure why this would be happening, but it seems related...

I ended up changing from using :center to :bounds on v-map and this was no longer a problem.
I calculate bounds from my points that I add in created() (stored to this.bounds) and use :bounds=bounds when calling the map.

Seems related to #34.

@brianmay seems to have identified the problem and even give some workaround. It seems like @xemoka workaround. Create a array object instead of passing :center="[49.5, -117]".

This should be fixed in v0.0.49

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RemiDesgrange picture RemiDesgrange  路  5Comments

Abdelaziz18003 picture Abdelaziz18003  路  4Comments

martinwithyou picture martinwithyou  路  4Comments

udos picture udos  路  4Comments

tiltec picture tiltec  路  4Comments