Display stations on a map using a MVT response

Rendering stations on a map can be done performant and secure by using a tile service. In this example, the MVT response format will be used. MVT stands for Mapbox Vector Tiles and can be used on a Mapbox map.

Requirements

Steps to take

  1. To render the tiles a tile service URL is required and requests made to Mapbox need to be transformed. Transforming the request helps with setting headers and controlling the tiles caching mechanism.
  2. After configuring the tile service URL and transforming the headers, it's required to set the filters. At least a power and connector filter needs to be present. This can be done by adding these as url query parameters.

Next steps

MVT is one format, but the Chargetrip tile response also supports GeoJSON. This will be explained in the next example.

  • index.js
  • map.js
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
          import { displayMap } from './map'; /** * This project shows you how to fetch a car list and render the car details * The project structure contains; * *    - map.js - All map rendering (tile server) */displayMap();