【问题标题】:Angular-Leaflet-Directive: Set opacity of a layerAngular-Leaflet-Directive:设置图层的不透明度
【发布时间】:2015-06-05 22:39:48
【问题描述】:

我正在使用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
            }
          }
        }
      });
    };
  }]);

我想更改包含多条路径的“地铁”叠加层的不透明度。

【问题讨论】:

    标签: angularjs leaflet angular-leaflet-directive


    【解决方案1】:

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

    感谢 Jonatas Walker 指出!

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 这如何解决我的问题?我想改变一个特定图层的不透明度。
      • 当创建该特定层时...使用此属性 - opacity。如果您需要更多帮助,请发布您的部分代码。
      • opacity 属性似乎什么都不做。我添加了我的地图初始化。我想更改包含多条路径的“地铁”叠加层的不透明度。
      【解决方案3】:

      试试这个:

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

      【讨论】:

      • 欢迎来到 Stack Overflow!额外的解释会改善你的答案。
      猜你喜欢
      • 1970-01-01
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      相关资源
      最近更新 更多