1

I'm making an app with Xamarin.Forms.Maps and then, I need to get all of the steps between two "place id" to make my own polyline. However, when I'm making my request, I get about only thirty five steps.

35 steps.. Between Le Mans (France) and Paris (France).. About 200km but only 35 steps.. The problem isn't that the two points aren't connected to the polyline made, no, the problem is that the polyline get out of the existing road..

Google API direction seems to give me, only, some important information, like important steps, but without following the road.. Does it normal?

PS: This is my request (I use Postman to test it)

https://maps.googleapis.com/maps/api/directions/json?origin=Le Mans&destination=Paris&key=[MY_API_KEY]&travel_mode=DRIVING
David Ansermot
  • 6,052
  • 8
  • 47
  • 82
Emixam23
  • 3,854
  • 8
  • 50
  • 107

1 Answers1

3

Are you using the polyline results in each driving step?

I used your example and got 31 start_location that each contain Encoded Polylines for drawing that path on the map.

The "Take the exit toward Paris-Centre Porte de Bercy" step results in:

"polyline": {
   "points": "mn_iHmxqM@[?WA_@Ck@CeAAMGcAEi@Gc@Ke@GUI[IYGSIMIKGECAMIMEA?EAA?A?K?I@A?C?IBE@C@?@C@GBOHEHGJIVIX_@j@"
 },

Decoded that is:

enter image description here

The "Take the exit on the left onto Bd Périphérique" step results in 91 points, etc...

There are hundreds and hundreds of locations points within the results, you just have to decode the locations of each driving step and plot them:

Google's Interactive Poly Line Utility

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • Ho ok thank for this answer, I didn't understand the polyline variable. I thought it was the encoded start/end location of the step. – Emixam23 May 12 '16 at 15:26
  • 1
    @MaximeGuittet here is one @ http://stackoverflow.com/a/3852420/4984832 Lots of others in C# around the web ;-) – SushiHangover May 12 '16 at 15:29
  • 1
    @MaximeGuittet Does that help you enough to plot all the points? – SushiHangover May 12 '16 at 15:31
  • Ho ok thank for this answer, I didn't understand the polyline variable. I thought it was the encoded start/end location of the step. I just took a look at your link, does it exists a way to decode it? [This link](https://developers.google.com/maps/documentation/utilities/polylinealgorithm#example) show how it's encoded, so I can do it "in the reserved way", but if something easier exists, it would be really nice ^^ – Emixam23 May 12 '16 at 15:38
  • Haha yep, one more time you helped me ;) – Emixam23 May 12 '16 at 15:39
  • If Encode() "Decode", it's a bit weird to call a function like it ^^ My last question then is, how can I call the method? Polyline is a string in the API response, the method wait an IEnumerable – Emixam23 May 12 '16 at 15:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/111784/discussion-between-maxime-guittet-and-sushihangover). – Emixam23 May 12 '16 at 15:52
  • 1
    Look at the `Decode` method @ https://gist.github.com/shinyzhu/4617989 That will give you the reverse (string to location coords) – SushiHangover May 12 '16 at 15:55