Pregunta

I developed an app that sends GPS points to a server and the server convert those GPS points into a path, which is shown in a map. Now the server makes a call to Google Maps Directions service and gets a response. From that response I use the value overview_polyline, which based on the documentation:

Contains an object holding an array of encoded points that represent an approximate path of the resulting directions.

The problem is that sometimes the line I get is really weird. Sometimes it gives me a path where there's no street at all.

Here are some screenshots to describe my problem. The yellow marker is the start point (A), and the blue marker is the end point (B).

Start and end points

So I asked Google to give a route from A to B, with driver mode, so it shows the actually path.

And this is the result:

Google Result

This is the API call I use. My question is: Any idea why would it return that path?

¿Fue útil?

Solución

http://www.geocodezip.com/v3_example_geo2.asp?addr1=53%20Imperial%20Avenue,%20Westport,%20CT%2006880,%20USA&addr2=2%20Harborview%20Road,%20Westport,%20CT%2006880,%20USA&geocode=1&geocode=2&type=m

Looks to me like the encoded polyline is not being rendered correctly. How is your code handling that?

example using the geometry library decodePath function

Looks to me like Google broke their polyline encoding.

If I paste it into here (which admittedly doesn't expect polylines, it expects polyons)

I need to escape the "`", change:

{pazFraw~L|@|@f@^`@N\\?XIx@a@n@[

to:

{pazFraw~L|@|@f@^\`@N\\?XIx@a@n@[

to make it have a more reasonable shape.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top