I have an array of 55 countries:
countries = ['Albania', 'Turkey', .....]
And I am looking to get a single array in the following form:
letlocations = [ ["Albania", 11.8166, 122.0942], ["Turkey", 11.9804, 121.9189], ..... ];
At the moment I have only been able to work with 1 location by using this code
const changeMapCenter = async () => {
const searchLocation = ['Madrid', 'London', 'Tokyo', 'Mexico City', 'Chicago', 'Munich', 'Machu Pichu']
let item = searchLocation[Math.floor(Math.random() * searchLocation.length)];
const searchURL = `${MAPBOX_PLACES_API}${item}${REST_PLACES_URL}`
const response = await fetch(searchURL)
const data = await response.json()
const result = data
const { coordinates } = result.features[0].geometry
const features = { coordinates }
const latlong = [...coordinates].reverse()
mymap.flyTo(latlong)
L.marker(latlong).bindPopup(`hola estás en ${item}`).addTo(mymap)
}
My question is how could I plot several countries at the same time?
Thanks for your help!