用于笔触,填充的单独颜色

问题描述 投票:0回答:1

我已在GeoJson的路径上添加了箭头。我想知道是否可以自定义笔触颜色与填充颜色不同?

这里是我尝试过的选项:

    {
      offset: "20%",
      repeat: "30%",
      symbol: L.Symbol.arrowHead({
        pixelSize: zoom * 2,
        pathOptions: {
          fillOpacity: 1,
          weight: 0,
          // fill: true,
          // fillColor: "#c71002",
          color: "#c71002",
          stroke: true,
          strokeColor: "#fff"
        }
      })
    }
  ]
reactjs leaflet react-leaflet polyline-decorator
1个回答
0
投票

实际上不支持strokeColor

为了获得类似边框的效果,可以指定以下属性(来自documentation

  • stroke设置为true(默认值)-确定是否沿路径绘制笔划。
  • [weight-笔划宽度(以像素为单位)
  • [color-笔触颜色

在场景arrowHead符号后面以多边形或折线的形式呈现。

示例

L.polylineDecorator(layer, {
  patterns: [
    {
      offset: "10%",
      repeat: "20%",
      symbol: L.Symbol.arrowHead({
        pixelSize: 25,
        pathOptions: {
          color: "#c71002",
          fillColor: '#fff',
          fillOpacity: 1,
          stroke: true,
          weight: 2,
        },
      }),
    },
  ],
}).addTo(map);

结果

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.