Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How to remove map route for HERE map API

I currently have a function drawing a map line when clicking on an option, however I only want one to be displayed at a time, so that when the user clicks on another option, it erases the previously drawn route, then draws a new one. I've tried to research how to do this but have come up with nothing.

function addRouteShapeToMap(route) {
  route.sections.forEach((section) => {
    let linestring = H.geo.LineString.fromFlexiblePolyline(section.polyline);
    let polyline = new H.map.Polyline(linestring, {
      style: {
        lineWidth: 8,
        strokeColor: "rgba(207, 0, 15, 1)",
      },
    });

    map.addObject(polyline);
  });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should be able to remove the polyline, or generally any added map object, with the method removeObject. This assumes you keep a reference to the polyline outside the function which adds it to the map, or else you could iterate over map objects retrieved with map.getObjects to find it.

map.removeObject(polyline);

See the API Reference

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!