簡體   English   中英

如何使用 Mapbox GL JS 中另一個 json 的數據條件設置樣式?

[英]How to style with data conditions from another json in Mapbox GL JS?

所以我有兩個 json 文件,第一個是火車站的幾何圖形,而第二個 json 文件是過去十年每個車站上下車的乘客數量(沒有幾何圖形)。

已作為圖層添加到地圖的第一個 json 文件中的 Stations Geometry Features(使用 Mapbox GL JS)

"type": "FeatureCollection",
"name": "stationen_offset500000",
"features": [
{ 
"type": "Feature", 
"properties": { 
        "np_id": 10312, 
        "station": "Somewhere Main Station",
        "gid": 1123 }, 
        "geometry": { "type": "Polygon", "coordinates": [ [ [ ...] ] ]}};

以及包含數據的 Entrants/Dropoff json 文件:

"type": "FeatureCollection",
"name": "einAussteiger",
"features": [
{ 
"type": "Feature", 
"properties": { 
        "np_id": 10038, 
        "station": "Somewhere Main Station", 
        "avg_entrants_day": "339,344", 
        "avg_dropoff_day": "391,266", 
        "year": 2018, 
        "id": 1 }}

我的目標是根據給定特定年份的 avg_entrants_day 設置站多邊形的擠壓高度。 但我真的不知道該怎么做,因為數據在兩個不同的 json 文件中。

我撥通了電話

map.setPaintProperty("stations_offset500000", 'fill-extrusion-height', [
  "match",
  ["get", "..."],
])

有各種版本,但老實說沒有用。

最簡單的方法很簡單:

  1. 獲取第一個文件。
  2. 獲取第二個文件。
  3. 循環第一個文件中的功能,添加第二個文件中的屬性。
  4. 將其添加到地圖中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM