GensaGames
GensaGames

Reputation: 5788

Extracting Google Map routes as shape

We have very simple example of transition route in Web Google Map. Consider following example link. Or image, below.

Or this Image.

My question is, how to get this shape of the route with some Map API(maybe not Google)? So I'm trying to make script, where I can insert a lot of points of the destination, and the output should be the shape of the transition routes. Even I can make shape with OpenCV, all what I need, it's just thumbnail of such route.


enter image description here

Another Example

enter image description here

Upvotes: 0

Views: 2653

Answers (1)

MrUpsidown
MrUpsidown

Reputation: 22486

Your question is now a bit too broad and so will be my answer, but I'll summarize here what you could do.

  1. Request your Directions with the JS API or the Directions API.
  2. Use Waypoints in your request to specify each point. Warning: limitations apply (23 waypoints + origin & destination).
  3. In your Directions response, you can use either the overview_path or the overview_polyline to draw that same route on the Maps Static API. Note that both are simplified paths (smoothed) that are less precise than the exact Polyline you get from the API. Maybe that is enough for your use case. Read more here.
  4. Alternatively, if you need the exact Polyline coordinates, you will have to extract it from each DirectionsStep returned by the API.
  5. Once you have your path points (or encoded Polyline), you can request your Maps Static API path (also see about encoded Polylines at the bottom of that page).

Hope this helps.

Upvotes: 1

Related Questions