Javascript 如何使用MapBox获取单个坐标数组?

Javascript 如何使用MapBox获取单个坐标数组?,javascript,leaflet,fetch,data-visualization,mapbox,Javascript,Leaflet,Fetch,Data Visualization,Mapbox,我有55个国家: countries=[‘阿尔巴尼亚’、‘土耳其’、…] 我希望得到以下形式的单个数组: letlocations=[“阿尔巴尼亚”,11.8166122.0942],“土耳其”,11.9804121.9189],…] 目前,我只能使用此代码处理1个位置 constchangemapcenter=async()=>{ const searchLocation=[“马德里”、“伦敦”、“东京”、“墨西哥城”、“芝加哥”、“慕尼黑”、“马丘比丘”] let item=searchL

我有55个国家:

countries=[‘阿尔巴尼亚’、‘土耳其’、…]

我希望得到以下形式的单个数组:

letlocations=[“阿尔巴尼亚”,11.8166122.0942],“土耳其”,11.9804121.9189],…]

目前,我只能使用此代码处理1个位置

constchangemapcenter=async()=>{
const searchLocation=[“马德里”、“伦敦”、“东京”、“墨西哥城”、“芝加哥”、“慕尼黑”、“马丘比丘”]
let item=searchLocation[Math.floor(Math.random()*searchLocation.length)];
const searchURL=`${MAPBOX\u PLACES\u API}${item}${REST\u PLACES\u URL}`
const response=等待获取(searchURL)
const data=wait response.json()
常量结果=数据
const{coordinates}=result.features[0]。几何图形
常量特征={坐标}
常量latlong=[…坐标].reverse()
mymap.flyTo(拉特朗)
L.marker(latlong).bindPopup(`hola estás en${item}`).addTo(mymap)

}
从研究
承诺开始,