angular-leaflet-directive icon indicating copy to clipboard operation
angular-leaflet-directive copied to clipboard

Can you change/update an overlay's opacity from angular?

Open nickponline opened this issue 12 years ago • 11 comments

I tried adding a button to my controller

$scope.onClick = function() { $scope.layers.overlays.myOverlay.layerOptions.opacity = 0.5; }

Although the value changes, the new opacity does not reflect on the map.

nickponline avatar Jan 15 '14 20:01 nickponline

You're correct that you cant right now. I just got back from vacation and I'm going to make an honest effort to figure out my build problems so I can start contributing - but in the meantime, I can offer this: cc8fadb9f01b52d431424274656d6467a29d4975

I quickly modified my working version to accommodate recent changes in master, I might have made a mistake. You have to call leaflet api methods on the layers to update the opacity or zIndex, so we can't handle them in a very generic way. Let me know if you have any problems. If this works right away, I could issue a pull request but I'll leave that up to everyone else.

See: https://github.com/tombatossals/angular-leaflet-directive/issues/215

ccrabb avatar Jan 15 '14 23:01 ccrabb

I just tried it and it works great. could you issue the pull request?

huaruiw avatar May 14 '14 19:05 huaruiw

actually it does reset the visibility of the overlays. So I had to work around that. If you could get that solved it'd be perfect.

huaruiw avatar May 15 '14 07:05 huaruiw

Any progress on this?

jpoehnelt avatar Jun 09 '14 21:06 jpoehnelt

@ccrabb please PR.

nmccready avatar Jun 23 '15 13:06 nmccready

Hi, layercontrol directive does it, an example here:

http://tombatossals.github.io/angular-leaflet-directive/examples/0000-viewer.html#/controls/custom-layer-control-example

This feature requires HTML5 browsers.

elesdoar avatar Sep 01 '15 03:09 elesdoar

Actually @elesdoar I think they know how to set the opacity. I think the issue is that updating the opacity doesn't work at a later point in time.

nmccready avatar Sep 01 '15 15:09 nmccready

Does anyone want credit for their work? Please make a PR; or do I have to pull it in manually. Please make our lives easier by making a PR through github.

nmccready avatar Sep 01 '15 15:09 nmccready

I think that it was not clear, layercontrol support change opacity and order in layers.

Click double down arrow

github1

Layer control show an opacity control

github2

But, the problem is that leaflet directive not watch opacity or z-index changes without layercontrol.

elesdoar avatar Sep 01 '15 16:09 elesdoar

Ok @elesdoar then we should be good "as is" and close right?

nmccready avatar Sep 01 '15 18:09 nmccready

For now, yes, soon I will fixing for be enough setting layer options anywhere...

elesdoar avatar Sep 01 '15 18:09 elesdoar