最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

mapbox gl js - circle-color is not displayed correctly - Stack Overflow

programmeradmin6浏览0评论

This is my setting for a circle

    map.addLayer({
        'id': _identifier,
        'type': 'circle',
        'source': _open,
        'paint': {
            'circle-radius': 26,
            'circle-stroke-width': 2,
            'circle-color': '#0099ff',
            'circle-stroke-color': 'green'
        }
    });

In the map the color is then not displayed correctly:

I wonder what the reason for this might be.

This is my setting for a circle

    map.addLayer({
        'id': _identifier,
        'type': 'circle',
        'source': _open,
        'paint': {
            'circle-radius': 26,
            'circle-stroke-width': 2,
            'circle-color': '#0099ff',
            'circle-stroke-color': 'green'
        }
    });

In the map the color is then not displayed correctly:

I wonder what the reason for this might be.

Share Improve this question asked Feb 5 at 8:42 Michael PerlbachMichael Perlbach 1273 silver badges11 bronze badges 9
  • According to the manual, paint properties are 'cheap' and therefore can't be relied on. docs.mapbox.com/style-spec/reference/layers/#paint-property – JMP Commented Feb 5 at 9:13
  • So "cheap" is synonymous for "unreliable" in this context? This is a very basic feature of Mapbox - so it should better not be unreliable. I am in contact with a Mapbox developer now. Once a solution is found I will post it here. – Michael Perlbach Commented Feb 5 at 10:01
  • Meaning 'rickety in structure and easily damaged'. I think if the property is changed a lot, it's value can't be accurately determined. – JMP Commented Feb 5 at 10:45
  • In my case there are not many changes to this property - and I wonder how an explicitly formulated hex value can't be accurately determined. It seems rather be related to the style I use - which should not be the case in my opinion. Setting colors programmatically should not be be dependant on a certain style. Let's see what the Mapbox developer finds out. – Michael Perlbach Commented Feb 5 at 10:51
  • Have you tried using different color directives? docs.mapbox.com/style-spec/reference/types/#color – JMP Commented Feb 5 at 11:32
 |  Show 4 more comments

1 Answer 1

Reset to default 0

After having communicated with the mapbox developer I got the solution.

So, for anyone with the same problem: mapbox has introduced a new feature - apparently not yet documented. This property is called "circle-emissive-strength" and can have float values between 0 and 1. As it seems: If not set, the default value is 0 - in this case the general color tone of the map style overrides the circle color.

Setting "circle-emissive-strength" to 1 restores the original circle color:

    map.addLayer({
        'id': _identifier,
        'type': 'circle',
        'source': _open,
        'paint': {
            'circle-radius': 26,
            'circle-stroke-width': 2,
            'circle-color': '#0099ff',
            'circle-emissive-strength': 1,
            'circle-stroke-color': 'green'
        }
    })
发布评论

评论列表(0)

  1. 暂无评论