TomTom Maps for JavaScript
    Preparing search index...

    Function getPlacesWithEVAvailability

    • Enhance multiple places with real-time EV charging availability data.

      Fetches availability information for all EV charging stations in a collection and merges it into their properties. Non-EV places and EV stations without availability data are returned unchanged.

      Type Parameters

      Parameters

      • places: Places<P>

        Collection of places to enhance

      • Optionaloptions: { excludeIfAvailabilityUnknown: true }

        Configuration options

      Returns Promise<Places<EVChargingStationWithAvailabilityPlaceProps>>

      Promise resolving to places collection with merged availability

      Important: Availability requests are made sequentially to avoid exceeding API rate limits (QPS - Queries Per Second). For large result sets, this may take some time.

      // Search for charging stations and add availability
      const results = await search({
      query: 'EV charging',
      at: [4.9, 52.3],
      radius: 5000
      });

      const withAvailability = await getPlacesWithEVAvailability(results, {
      excludeIfAvailabilityUnknown: true // Filter out stations with unknown availability
      });

      // Display only stations with known availability
      withAvailability.features.forEach(place => {
      const available = place.properties.chargingPark?.availability?.chargingPointAvailability.count;
      console.log(`${place.properties.poi?.name}: ${available} chargers`);
      });