Thailand EV Roadtrip
Thailand is becoming the new hub for electric vehicle production in Asia, with plans to switch 50% of the country's total car production to EVs by 2030. Previously, we also released an interactive map that lets you compare how far you can go from any point in Thailand using EV types with HERE Isoline API and a map displaying the EV charging deserts across Thailand, showing the number of stations per 100,000 people and per 10 square km, for each district, using data from HERE Charge Points API.
In this series of EV Routing samples, we are going to show how to add multiple via waypoints when calculating a route using HERE Routing API. To showcase this functionality we are going to calculate the EV car route from some of the biggest cities in Thailand from Chiang Rai (North) to Hat Yai (South) via Chiang Mai, Udon Thani, Khon Kaen, Chaophraya Surasak, and Bangkok. This is based on the previous blog on building a simple sample showing EV routing features of the HERE Routing API using HERE Maps API for Javascript.
To add via waypoints to the route calculation, we need to use the 'via' parameter in the query parameters to the HERE Routing API. A via waypoint is a location between origin and destination. The route will do a stop at the via waypoint. Multiple waypoints can also be specified using multiple via parameters like via=...&via=...
, in which case the route will traverse these waypoints sequentially in the order specified in the request. To learn more about the 'via' parameter check out this documentation page.
const EVorigin = '19.910480,99.840576'; //Chiang Rai
const waypoints = [
'18.796143,98.979263', //Chiang Mai
'17.413841,102.787233', //Udon Thani
'16.439625,102.828728', //Khon Kaen
'13.1244,100.9996', // Chaophraya Surasak
'13.736717,100.591507' //Bangkok
];
const EVdestination = '7.00836,100.47668'; //Hat Yai
function calculateRouteFromAtoB(platform) {
var router = platform.getRoutingService(null, 8),
routeRequestParams = {
'transportMode': 'car',
'origin': EVorigin,
'via': new H.service.Url.MultiValueQueryParameter(waypoints),
'destination': EVdestination,
'ev[makeReachable]':'true',
... //other routing parameters
};
router.calculateRoute(
routeRequestParams,
onSuccess,
onError
);
}
This is what the app looks like,
That is all for part 3, we hope you find this useful and give this a try. If you are interested in trying this sample, here is the source code of this sample. Stay tuned for the next part as we continue to add more functionalities to this application.
Have your say
Sign up for our newsletter
Why sign up:
- Latest offers and discounts
- Tailored content delivered weekly
- Exclusive events
- One click to unsubscribe