Embed

Add the planner to a React app as a component, or to any website with one script tag and a custom element. No build step or iframe is needed for the script widget.

Live example

This frame shows a plain HTML page served by this app at /embed-example.html. Its relative script URL works here because the page shares this app's origin. Use the absolute URLs in the snippet below on another website.

Add it to your page

HTML
<script src="https://YOUR-PLANNER-HOST.example/widget/evrp-route-planner.js" crossorigin="anonymous"></script>

<ev-route-planner
  lang="en"
  api-base-path="https://YOUR-PLANNER-HOST.example/api"
  image-base-path="https://YOUR-PLANNER-HOST.example"
  origin="Los Angeles, CA"
  destination="Las Vegas, NV"
  vehicle-model-id="tesla:model3:2024:lr:awd"
  start-soc-percent="90"
  min-soc-percent="10"
></ev-route-planner>

Reference

Both versions call this app's public HTTP API. To call it from your own code instead, see the API reference.

Attributes

origin
Starting address or place name, for example Los Angeles, CA.
destination
Destination address or place name.
vehicle-model-id
Vehicle catalogue ID, for example tesla:model3:2024:lr:awd. Omit it to let visitors choose their EV.
start-soc-percent
Starting battery charge, from 0 to 100 percent.
min-soc-percent
Minimum battery charge to keep, from 0 to 100 percent.
vehicle-options
JSON array of { id, label } to restrict or relabel the vehicle picker. Defaults to the full catalogue.
api-base-path
Absolute URL of the planning API when this widget is on another website.
image-base-path
Absolute origin serving catalogue vehicle photos when this widget is on another website.
lang
Interface language: en or es. Defaults to the visitor's browser language.
street-view-api-key
Optional Google Maps browser key authorized for your domain and the Street View Static and Maps Embed APIs. Shows charger Street View previews.
brand
branded (default) or neutral. See Theming below.
mode
light (default) or dark.

Events

trip-planned
Fires after planning a trip. event.detail contains the full plan, including route, stops and energy use.

Theming

brand / mode attributes
Set brand=neutral and/or mode=dark on the element to change the widget theme.
--evrp-*
Namespaced color, radius, shadow and font properties used by the component. See packages/react/src/styles/tokens.css.
EV Route Planner · Routing by OpenRouteService · Charger data from Open Charge Map