且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mapbox GL JS刷新层

更新时间:2023-01-01 21:38:31

我'我有点困惑你正在尝试做什么(我不知道Chroma是什么),但看起来你正试图以某种方式动态更新Mapbox托管的矢量图块源的属性。你不能这样做。

I'm a bit confused about what you're trying to do (I don't know what Chroma is), but it looks like you are trying to somehow dynamically update properties of a vector tile source hosted on Mapbox. You can't do this.

你基本上有两个动态数据可视化选项:

You basically have two options for a dynamic data visualisation:


  1. 在浏览器中生成GeoJSON,并调用 map.setData()显示它。

  2. 保留地图数据静态,但生成一个巨大的数据驱动属性来可视化它:如果状态名称= X,则将其绘制为淡粉色。如果状态名称= Y,则将其绘制为淡蓝色等。

  1. Generate a GeoJSON in the browser, and call map.setData() to display it.
  2. Keep the map data static, but generate a huge data-driven property to visualise it: "If state name = X, draw it pale pink. If state name = Y, draw it pale blue" etc.

如果你已经拥有了瓷砖组中的所有数据和所有地理位置,那么我不清楚你的问题是什么,或者为什么你有刷新它的麻烦。只需调用 setPaintProperty 甚至 setStyle 即可更新可视化。

If you already have all the data and all the geographies in the tileset, then I'm not clear on what your problem is, or why you have trouble "refreshing" it. Just call setPaintProperty or even setStyle to update the visualisation.