Customise your route planning with HERE Routing API
Blog|23 March 2020
For business planning use cases it is often not just a case of simple routing from A to B. At Grey Matter, we receive a lot of requests from customers who have specific requirements when routing, and how to avoid a certain area is one of those.
Loading your own route specifications can ensure you are able to calculate routes that avoid options such as individual roads, particular areas, and more, according to your requirements.
In this insightful blog post, we are taken through the steps to build a custom route that uses bounding boxes to avoid areas.
Select your waypoints
We start with two waypoints, a routing mode (in this example, we’re asking for the fastest route by car) and an API key for authentication.
Display the route on a map
This example can be accessed via the Web SDK to see how to display a route on map. You will find that the JavaScript API uses the same routing parameters as the REST API – this code snippet calls the Routing API in JS.
Customise the route
We want to make sure that this route avoids a specific area, so to customise our route we can use the avoidareas parameter of the Routing API. We need to pass it a bounding box using two locations (top-left and bottom-right of the box).
The next step is to draw this area on the map and see if the new route we have created takes a path around the area we wanted to specifically avoid.
Referring back to the Web SDK, if you want to draw the area on the map using the Web SDK, you can use a map object such as H.map.Rect following the example in the code snippet below:
Add more areas to avoid
Now we have customised our map to avoid that area, we can now add another area to avoid. The Routing API supports avoiding up to 20 areas at once. We simply add more bounding boxes and separate them with an exclamation mark.
Let’s draw this on a map to check and see the route we have customised.
Grey Matter is the official distributor of HERE Technologies. Our location solutions team are experts in HERE solutions and licensing and can help you with your use case and get you set up with a HERE Freemium account. Contact them: +44 (0)1364 655 133 or here@greymatter.com
This blog is based on an original article by Richard Süselbeck, Principal Developer Evangelist for HERE Technologies.
Contact Grey Matter
If you have any questions or want some extra information, complete the form below and one of the team will be in touch ASAP. If you have a specific use case, please let us know and we'll help you find the right solution faster.
By submitting this form you are agreeing to our Privacy Policy and Website Terms of Use.
Related News
Copilot Week: Volume Two
After the success of the first version in February of this year, Microsoft has decided to host a second edition of Copilot Week, from 8-11 April 2024! This event will bring attendees into the world of Copilot, offering inspiration and...
Microsoft 365 and Azure Security Tools: Video One
The first in our series of short videos covering Microsoft 365 and Azure security tools is available now!
This series will be covering off the key tools and concepts you need to know about to secure your Microsoft 365 work environment. This is an essential step in preparing if your business is looking to adopt Microsoft 365 Copilot in 2024.
The 5 steps to adopt Microsoft 365 Copilot
Since Microsoft 365 Copilot’s release it has been one of the hottest software tools of 2024, with many businesses viewing it as a tool than can not only improve productivity and boost creativity but revolutionise the way they work. Indeed,...
[WEBINAR] Introducing CyberSmart
Wed 17 April 2024 3:00 pm - 4:00 pm BST
End-to-End Assurance Grey Matter is proud to partner with CyberSmart, providing easy-to-use technology and certifications to empower organisations of all sizes to fight cyber threats. Join our webinar to learn more about CyberSmart and what they do. During the webinar,...