Query stations around
To display stations at a certain location and display them on a map, the stationAround query can be used. This query can be combined with some additional filters for more precise results.
View on Github
- Chargetrip API key - to fetch stations all over Europe instead of a subset
- Mapbox API key - to display the map
- URQL - a lightweight graphQL client
- Start by implementing the
stationAroundquery requires a GeoJSON location and the distance around this GeoJSON location as arguments. Optionally a
amenityfilter can be applied to plot stations that meet the requirements.
- In this example the
amenityare dynamic. To do so, additional logic is written to request new data everytime one of these filters are updated.
- With this logic in place, it's time to render the stations onto a map based on their location. The availability of the station will also be taken into account to show the differences on the map.
After stations are available on a map, fetching additional station data on interaction is a logical next step. So let's move onto the next example to fetch data such as chargers, predicted availability, amenities or operator details.