Search code examples
angularjsleafletangular-leaflet-directive

Angular-Leaflet-Directive: Set opacity of a layer


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.


Solution

  • 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!