【问题标题】:leaflet tile layer add background color using Css class传单平铺层使用 Css 类添加背景颜色
【发布时间】:2020-04-27 11:02:31
【问题描述】:

如何为地图切片图层添加自定义背景颜色。使用 css 类?

function initLayer(item, map) {
  const stateLayer = L.geoJSON(item, {
    style: function(feature) {
       return {
        weight: 8,
        opacity: 1,
        color: '#333',
        fillOpacity: 1,
        className: 'gradient-class' // add custom class
      }
    },
  });
  map.addLayer(stateLayer);
} 

【问题讨论】:

  • 您无法更改图块的颜色。瓷砖是一组图像。您只能使用不同的磁贴提供程序

标签: css angular leaflet


【解决方案1】:

您可以更改地图的背景。 (加载瓦片时默认为灰色背景)

#map{
   background-color: #bb4040;
}

如果您想更改图块颜色,可以使用 css 过滤器:https://stackoverflow.com/a/60431006/8283938

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    相关资源
    最近更新 更多