Mapbox GL JS:更改多边形边框宽度

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

我在地图上有一个简单的多边形,我只想调整边框颜色宽度。 (geoJSON是外部的)我无法在the API manual中找到它。

This is a link to my example(和来源)。

目前我的多边形样式代码是:

'paint': {
'fill-color': 'rgba(60, 120, 40, 0.4)',
'fill-outline-color': 'rgba(20, 100, 25, 1)'
}

我应该添加什么来使边框更宽?对于我缺少的简单多边形,还有其他样式选项吗? (因为我找不到关于此的文档。)

我在我的问题下面张贴了一张图片 - 基本上边框在图像的左侧定义得很好,但是如果用户改变视角,则很难看到,因为宽度太小。

geoJSON border issue image

mapbox geojson mapbox-gl-js
1个回答
4
投票

由于technical reasons样式的fill,您不能指定大于1的边框宽度。使用带有线条样式的附加图层:

  map.addLayer({
    'id': 'states-layer-outline',
    'type': 'line',
    'source': {
      'type': 'geojson',
      'data': 'test.js'
    },
    'paint': {
      'line-color': 'rgba(255, 0, 0, 1)',
      'line-width': 4
    }
  });  

[Qazxswpoi]

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