如何在 Mapbox GL JS 中使用来自另一个 json 的数据条件设置样式?
How to style with data conditions from another json in Mapbox GL JS?
所以我有两个 json 文件,第一个是火车站的几何图形,第二个 json 文件是有多少乘客在 on/off过去十年的每个站点(没有几何图形)。
第一个 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", "..."],
])
各种版本,老实说没用
最简单的方法就是:
- 获取第一个文件。
- 获取第二个文件。
- 循环第一个文件中的特征,添加第二个文件中的属性。
- 将其添加到地图中。
所以我有两个 json 文件,第一个是火车站的几何图形,第二个 json 文件是有多少乘客在 on/off过去十年的每个站点(没有几何图形)。
第一个 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", "..."],
])
各种版本,老实说没用
最简单的方法就是:
- 获取第一个文件。
- 获取第二个文件。
- 循环第一个文件中的特征,添加第二个文件中的属性。
- 将其添加到地图中。