Angular-Leaflet-Directive:设置图层的不透明度

时间:2015-06-05 22:39:49

标签: angularjs leaflet angular-leaflet-directive

我正在使用angular-leaflet-directive。是否可以选择更改图层的不透明度?

使用'常规'传单,我可以使用layer.setOpacity(0.5)。但是在angular-leaflet-directive中似乎没有选项。

编辑: 这是我的传单配置:

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
            }
          }
        }
      });
    };
  }]);

我想改变包含多条路径的'subway'覆盖层的不透明度。

3 个答案:

答案 0 :(得分:1)

看起来这还没有实现: https://github.com/tombatossals/angular-leaflet-directive/issues/251

感谢Jonatas Walker指出它!

答案 1 :(得分:0)

您是否阅读过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
        }
    });
}]);

答案 2 :(得分:-1)

尝试使用:

overlays: {
            subway: {
              name: 'Subway',
              visible: true,
              type: 'group',
              layeroptions: {
                   opacity: 0.1   
              }
            },
          }