我下面有一個(gè)回調(diào)函數(shù),該函數(shù)能夠從Eventbrite API生成數(shù)據(jù)。目前,此功能可以通過(guò)“新標(biāo)記”方法在我的Mapbox地圖上生成標(biāo)記。但是,我想通過(guò)“ Mapbox addLayer”方法將這些數(shù)據(jù)生成到地圖上的圖層中,而不是使用標(biāo)記。 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} ); }});我基本上想要這個(gè),它根據(jù)幾何的坐標(biāo)在地圖上生成符號(hào),但是使用API數(shù)據(jù)。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" } },任何幫助深表感謝!謝謝你
有沒(méi)有一種方法可以將API數(shù)據(jù)轉(zhuǎn)換為Mapbox圖層?
慕妹3146593
2021-05-04 21:41:06