Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
743 views
in Technique[技术] by (71.8m points)

api - google map static drawing "route" instead of straight line

I succeeded in getting a google static map displaying a path between 2 coordinates.

The problem is that the drawn path is just a straight line between the 2 points.

I read that to be able to draw the "route" between 2 points on a static google map, as in, following the roads and city geography instead of the straight line, I need to add all the coordinates/crossroads for the path.

Does anyone knows an easy solution to solve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can definitely do this with the Static Maps API:

get directions using DirectionsService:

http://code.google.com/apis/maps/documentation/javascript/reference.html#DirectionsService

and convert the overview path to suit the requirements of the Static Maps API:

http://code.google.com/apis/maps/documentation/staticmaps/#Paths


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...