Vue2leaflet: Add attribute to control scrollWheelZoom option

Created on 19 Sep 2018  路  4Comments  路  Source: vue-leaflet/Vue2Leaflet

Leaflet has an option called scrollWheelZoom, but Vue2Leaflet doesn't support it.

As a workaround for now, I have this code in my root component:

  mounted() {
    // Hack to turn off scrollWheelZoom, since vue2-leaflet doesn't support it
    this.$nextTick(() => {
      let map = this.$refs.map.mapObject;
      let layers = [];
      map.eachLayer(l => {
        layers.push(l);
      });
      let options = { ...map.options, layers: layers, scrollWheelZoom: false };
      map.remove();
      this.$refs.map.mapObject = L.map(this.$refs.map.$el, options);
    });
  },

(This require <l-map ref="map"> to be set.)

I would prefer to just set <l-map :scroll-wheel-zoom="false">.

Most helpful comment

You can simply do:

<l-map :options="{scrollWheelZoom:false}"

Options prop gets bound to leaflet options

All 4 comments

You can simply do:

<l-map :options="{scrollWheelZoom:false}"

Options prop gets bound to leaflet options

@carlmjohnson if my answer satisfy your needs please close the issue :)

Awesome, thanks! Can this be added to the docs somewhere? I searched the repo for scrollWheelZoom and didn't find it.

I am thinking to make a big doc pr I will make an issue about it today, any help would be welcomed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lusman20 picture lusman20  路  4Comments

martinwithyou picture martinwithyou  路  4Comments

shtw picture shtw  路  5Comments

DmitriyVTitov picture DmitriyVTitov  路  4Comments

zaqisilverano picture zaqisilverano  路  4Comments