vue-leaflet/Vue2Leaflet

Reload marker when opacity changes

Nisgrak opened this issue · 2 comments

Description

If I set opacity in options prop only works with initial value, is not reactive.

Maybe a opacity prop that recreate the marker with the new value

Live Demo

http://jsfiddle.net/e2fy5dpq/

Steps to Reproduce

  1. Pass an options object with opacity prop to a marker
  2. Change the value of opacity

Expected Results

Change the opacity of the marker

Actual Results

Nothing

Browsers Affected

  • [ x] Chrome
  • [ x] Firefox
  • [x ] Edge
  • [x ] Safari 9
  • [x ] Safari 8
  • [x ] IE 11

Versions

  • Leaflet: v1.7.1
  • Vue: v2.6.12
  • Vue2Leaflet: v2.52
mikeu commented

Hi @Nisgrak , thanks for reporting this! I have confirmed that this is happening because the underlying Leaflet method setOptions does not affect a marker's opacity, despite opacity being one of its options. If you look at the marker object you'll see that with your code, the opacity property of the Leaflet Marker object does get updated, that just doesn't actually get passed on to the style, apparently.

I can add an opacity prop to the LMarker component and have it call the marker's setOpacity method directly instead.

I would love that ❤️