plotting a route on Google Maps

前端 未结 3 1461
Happy的楠姐
Happy的楠姐 2020-12-04 09:55

How would I use Google Maps API to plot a route? E.g to have a bunch of way points loaded onto the map (I currently have this) and draw a line from each of them showing the

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 10:44

    I've done this on Android. Google has a service for this here is the link https://developers.google.com/maps/documentation/roads/intro

    You'll find an example API call on this page here. Plus some web instructions. https://developers.google.com/maps/documentation/roads/snap

    This is an example web call to the service. https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907|-35.28099,149.12929|-35.28144,149.12984|-35.28194,149.13003|-35.28282,149.12956|-35.28302,149.12881|-35.28473,149.12836&interpolate=true&key=YOUR_API_KEY

    If memory serves, I believe you can have up to 100 points per call and you get charged by each call regardless of the amount of points.

    This above call can also be configured to snap to roads.

    As far as drawing the routs when the map loads, this depends on what technologies you are using. I know that it's easy to in .NET WinForms

    If you post a comment on your question; letting me know what technologies you are using I may be able to give you some further advice.

    If you want to test your routes for free, I found a nifty little web site: https://www.darrinward.com/lat-long/

    Hope this helps.

提交回复
热议问题