1

I am using the angular-leaflet-directive. Is there an option to change the opacity of a layer?

With 'regular' leaflet I can use layer.setOpacity(0.5). But there seems to be no option in the angular-leaflet-directive.

Edit: here is my leaflet configuration:

angular.module('epic-taxi')
  .controller('MainController', ['$scope', function($scope) {

    $scope.initMap = function() {
      angular.extend($scope, {
        newYork: {
          lat: 40.7304783951045,
          lng: -73.98880004882812,
          zoom: 12
        },
        layers: {
          baselayers: {
            mapbox_light: {
              name: 'Light',
              type: 'xyz',
              url: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png'
            }
          },
          overlays: {
            subway: {
              name: 'Subway',
              visible: true,
              type: 'group',
              opacity: 0.1    // not working
            }
          }
        }
      });
    };
  }]);

I want to change the opacity of the 'subway' overlay which contains multiple paths.

fwind
  • 1,274
  • 4
  • 15
  • 32

3 Answers3

1

It looks like this is not implemented yet: https://github.com/tombatossals/angular-leaflet-directive/issues/251

Thanks to Jonatas Walker for pointing it out!

fwind
  • 1,274
  • 4
  • 15
  • 32
0

Did you read their docs?

app.controller("CenterController", [ '$scope', function($scope) {
    angular.extend($scope, {
        center: {
            lat: 40.095,
            lng: -3.823,
            zoom: 4,
            opacity: 0.5
        },
        defaults: {
            scrollWheelZoom: false
        }
    });
}]);
Jonatas Walker
  • 13,583
  • 5
  • 53
  • 82
  • How does that solve my problem? I want to change the opacity of one particular layer. – fwind Jun 07 '15 at 13:27
  • When the creation of that particular layer ... use this property - `opacity`. If you want more help, post part of your code. – Jonatas Walker Jun 08 '15 at 09:25
  • The opacity property seems to do nothing. I added my map initialization. I want to change the opacity of the 'subway' overlay which contains multiple paths. – fwind Jun 08 '15 at 10:08
  • It looks like they're working on it ... https://github.com/tombatossals/angular-leaflet-directive/issues/251 – Jonatas Walker Jun 08 '15 at 10:56
-1

Try using this:

overlays: {
            subway: {
              name: 'Subway',
              visible: true,
              type: 'group',
              layeroptions: {
                   opacity: 0.1   
              }
            },
          }
ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
Alexus
  • 1,282
  • 1
  • 12
  • 20