Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda