简体   繁体   English

圆半径的Mapbox setPaintProperty不更新图层

[英]Mapbox setPaintProperty for circle-radius is not updating layer

I have a Mapbox circle layer and I need to change the radius of the circle but the setPaintProperty method doesn't seem to work. 我有一个Mapbox圆形图层,我需要更改圆形的半径,但是setPaintProperty方法似乎不起作用。 The layer displays initially: 该层最初显示:

map.addLayer({
        "id": "circleCurrentGpsCircle",
        "type": "circle",
        "source": "source_circleCurrentGpsCircle",
        "paint": {
          "circle-radius": {
            stops: [
              [0, 0],
              [22, metersToPixelsAtMaxZoom(gpsAccuracyWidth, currentLatitude)]
            ],
            base: 2
          },
          "circle-color": self.props.senData.gpsCircleShading ? "#FFFF00" : "transparent",
          "circle-opacity": 0.3,
          "circle-stroke-width": 3,
          "circle-stroke-color": "#FFFF00"
        }
      });

I then call the following to change the radius of the circle: 然后,我调用以下命令更改圆的半径:

var radiusData = {
        stops: [
          [0, 0],
          [22, metersToPixelsAtMaxZoom(gpsAccuracyWidth, currentLatitude)]
        ],
        base: 2
      };
      this.map.getLayer('circleCurrentGpsCircle').setPaintProperty('circle-radius', radiusData);

The circle doesn't change though. 圆圈没有改变。 I'm not getting any errors in the console. 我在控制台中没有任何错误。

Normally, one calls setPaintProperty on the map object itself, not on a layer: 通常,一个调用是在map对象本身而不是在图层上调用setPaintProperty的:

this.map.setPaintProperty('circleCurrentGpsCircle', 'circle-radius', radiusData);

I've never noticed the setPaintProperty() method on the returned layer object, but in my brief testing, it doesn't seem to work for me either. 我从没注意到返回的图层对象上的setPaintProperty()方法,但是在我的简短测试中,它似乎也对我不起作用。

(Actually with a bit of further testing, it seems that values set through that function do get recorded somewhere, and when you later call map.setPaintProperty() , all those values now get displayed. But this doesn't help you - just change the line to what I provided above.) (实际上,经过一些进一步的测试,似乎通过该函数设置的值确实记录在某处,并且当您稍后调用map.setPaintProperty() ,所有这些值现在都会显示出来。但这对您没有帮助-只是更改行到我上面提供的内容。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM