Skip to main content

Calculate an EV Route

Problem: Route an electric vehicle to a destination it cannot reach on its current charge.
This is not car routing with a range filter. The vehicle’s ability to reach charger three depends on whether it stopped at charger one.You cannot approximate it by post-processing a car route against a charger database.

Prerequisites

  • A HERE API key with Routing entitlement
  • export HERE_API_KEY="..."
EV routing is a capability within the Routing API, at the same router.hereapi.com/v8/routes endpoint. It is not a separate service.The HERE EV Charge Points API — for finding and describing charging infrastructure — is a different product with a separate entitlement. A key that routes EVs may return 403 from charge points.

The code

Response walkthrough

With EV parameters enabled, each section’s departure and arrival blocks carry the battery charge at that point, and charging stops appear as postActions.
summary.duration is drive time only. The charging stop’s duration is separate, in postActions.A UI that shows summary.duration as the ETA has silently omitted 33 minutes of charging. Sum both.

Key parameters

Common mistakes

Filtering a car route against a charger table. Assuming full charge. Nearly every real dispatch begins at partial charge. Omitting ev[makeReachable]. An unreachable destination returns no route rather than a route with a charging stop. A linear consumption model. Highways and grades break it. Ignoring auxiliaryConsumption. Refrigerated vans in July. Reading only summary.duration. Charging time is in postActions. Hiding the charging stop inside the polyline. Drivers and dispatchers both need it surfaced. Routing commercial EVs against passenger charging data. Different connectors, inaccessible sites. HERE documents EV truck charging as a distinct concern. Assuming your routing key queries charge points. Separate entitlement. Treating charger availability as static. A confidently routed truck arriving at an occupied charger, with no range to reach an alternative, is worse than no routing.

Production considerations

Energy profile is model data. Battery capacity, consumption curve, connector types, charging curve. On the vehicle record. Never at a call site. Pre-check feasibility cheaply. Range versus straight-line distance rejects most infeasible assignments before you compute anything. See Fleet Electrification. Use live state of charge where telematics provides it. Disclose the assumption where it does not. Model the charging stop as a schedule event. The vehicle is unavailable for 33 minutes. Cache the charger network, not availability. Stations move slowly. Availability changes by the minute — and availability is a query against the EV Charge Points API, a separate product. Cap maxChargeAfterChargingStation. Charging from 80% to 100% takes disproportionately long. chargingCurve encodes this; setting the cap uses it.

EV Routing

Routing versus charge points, and the two-product distinction.

Fleet Electrification

Answering feasibility before you buy trucks — usually without this API.

EV Charging Applications

The dispatch-time architecture.

Calculate an Isochrone

range[type]=consumption — everywhere reachable on this charge.

HERE documentation


Need production HERE API keys or implementation support? Placematic is an official HERE Technologies reseller and implementation partner. Talk to us.