Last active
February 22, 2020 06:10
-
-
Save thewarpaint/82cd81abfdb32781f6271242ea46c0b3 to your computer and use it in GitHub Desktop.
Ecobici
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = 'https://www.ecobici.cdmx.gob.mx/availability_map/getJsonObject'; | |
async function getData() { | |
const response = await fetch(url, { method: 'POST' }); | |
const stations = await response.json(); | |
return { | |
type: 'FeatureCollection', | |
features: stations.map(mapStation), | |
}; | |
} | |
function mapStation(station) { | |
return { | |
type: 'Feature', | |
geometry: { | |
type: 'Point', | |
coordinates: [ | |
station.lon, | |
station.lat, | |
] | |
}, | |
properties: { | |
id: station.id, | |
address: station.address, | |
district: station.district, | |
name: station.name, | |
nearby_stations: station.nearbyStations.split(','), | |
station_types: station.stationType.split(','), | |
zip_code: station.zip, | |
}, | |
}; | |
} | |
getData() | |
.then((collection) => console.log(JSON.stringify(collection, null, 2))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment