This is the documentation of version 0.61.0. Go to the latest version, 1.0.0-rc.5.
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, returned in the same order

      • options: Omit<ChargingStationsAvailabilityParams, "id"> & {
            excludeIfAvailabilityUnknown?: boolean;
            maxConcurrentRequests?: number;
        } & { excludeIfAvailabilityUnknown: true }

        Configuration options, including common service parameters (e.g. apiKey, onAPIRequest, signal) forwarded to each availability request

        • OptionalexcludeIfAvailabilityUnknown?: boolean

          If true, places with unknown availability are filtered out. Otherwise, they are returned unchanged.

          false
          
        • OptionalmaxConcurrentRequests?: number

          The most availability requests in flight at once. Values below 1 count as 1.

          Each request counts against your API key's QPS (queries per second) limit. The SDK retries a rate-limited (429) request with backoff bounded by the global retry.timeoutMs, so a value above that limit slows the call down; a request still rejected leaves its place with unknown availability.

          1
          
        • excludeIfAvailabilityUnknown: true

      Returns Promise<Places<EVChargingStationWithAvailabilityPlaceProps>>

      Promise resolving to places collection with merged availability

      One request per station, at most maxConcurrentRequests at a time — one by default, so a large result set takes as many round trips in series. A failed request leaves its place with unknown availability rather than failing the call.

      Pass a signal to stop early: aborting it cancels the in-flight requests, skips the remaining ones and rejects with SDKAbortError. Needs the same API key access as evChargingStationsAvailability.

      // Search for charging stations and add availability
      const results = await discoverPlaces({
      query: 'EV charging',
      geoBias: { position: [4.9, 52.3], radiusMeters: 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 { count, statusCounts } = place.properties.chargingPark.availability.chargingPointAvailability;
      console.log(`${place.properties.poi?.name}: ${statusCounts.Available ?? 0} of ${count} chargers available`);
      });
    • 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, returned in the same order

      • Optionaloptions: PlacesWithEVAvailabilityOptions

        Configuration options, including common service parameters (e.g. apiKey, onAPIRequest, signal) forwarded to each availability request

      Returns Promise<Places<P | EVChargingStationWithAvailabilityPlaceProps>>

      Promise resolving to places collection with merged availability

      One request per station, at most maxConcurrentRequests at a time — one by default, so a large result set takes as many round trips in series. A failed request leaves its place with unknown availability rather than failing the call.

      Pass a signal to stop early: aborting it cancels the in-flight requests, skips the remaining ones and rejects with SDKAbortError. Needs the same API key access as evChargingStationsAvailability.

      // Search for charging stations and add availability
      const results = await discoverPlaces({
      query: 'EV charging',
      geoBias: { position: [4.9, 52.3], radiusMeters: 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 { count, statusCounts } = place.properties.chargingPark.availability.chargingPointAvailability;
      console.log(`${place.properties.poi?.name}: ${statusCounts.Available ?? 0} of ${count} chargers available`);
      });