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

263
Views
Google Maps Directions API in some cases returns polylines that looks like walk on water, across buildings etc

I am using the following library: googlemaps/google-maps-services-js

I am generating routes by inserting start/end point, waypoints, mode etc.

I am using the "overviewPolyline" that is returned from calling to directions() call to get the route's polyline. When viewing the line on a map it shows (in some cases) routes that goes on water\through buildings\road etc. what I need of course is a line that is coherent with the commute method selected (e.g driving).
enter image description here

now, I made a research online, read documentation, read lots of answers here on SO. I saw t2 options:

  1. replace "\\" (double backslash) with "\"
  2. create some algorithm to calculate it by myself by the "steps" returned from directions() call

My results are:
After trying #1 - It fixed some of the cases. but I still see lot of them. (not sure exactly when it happens and when it isn't) I have some idea that I wanted to check that may be the number of points on the polyline is limited and therefore is happens only in long distance routes. but I couldnt find anything about length-limit of polyline in the documentation

After trying #2 - it didn't make sense to me. and it really didnt work well..

Anyone has a suggestion of a solution for that? (or an approval the polyline route distance, or number of points is limited)

about 4 years ago · Juan Pablo Isaza
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!