为了账号安全,请及时绑定邮箱和手机立即绑定

有没有一种方法可以将API数据转换为Mapbox图层?

有没有一种方法可以将API数据转换为Mapbox图层?

慕妹3146593 2021-05-04 21:41:06
我下面有一个回调函数,该函数能够从Eventbrite API生成数据。目前,此功能可以通过“新标记”方法在我的Mapbox地图上生成标记。但是,我想通过“ Mapbox addLayer”方法将这些数据生成到地图上的图层中,而不是使用标记。    callbackEventbrite(function(result){    const keys = Object.values(result);    for(const key of keys){        geojson = {            type: 'featureCollection',            features: [{                type: 'feature',                geometry: {                    type: 'Point',                    coordinates: [key.venue.longitude, key.venue.latitude]                }            }]        }        eventInfo.push(            {"longitude": key.venue.longitude , "latitude": key.venue.latitude , "name": key.name.text, "venue": key.venue.name, "date": key.start.local, "category": key.category_id}        );    }});我基本上想要这个,它根据几何的坐标在地图上生成符号,但是使用API数据。map.addLayer({        "id": "locations",        "type": "symbol",        "source": {            "type": "geojson",            "data": {                "type": "FeatureCollection",                "features": [                    {                      "type": "Feature",                      "properties": {                        "Title": "The Congress Inn",                        "Description": "Pub located in Longton",                        "Type": "Pub",                        "Address": "14 Sutherland Rd, Stoke-on-Trent ST3 1HJ",                        "Longitude": 2.1316,                        "Latitude": 52.9878,                        "icon": "bar"                      },                      "geometry": {                        "coordinates": [                          -2.131836,                          52.987238                        ],                        "type": "Point"                      }                    },任何帮助深表感谢!谢谢你
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 170 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信