javascript 在谷歌地图上绘制路线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17316022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 07:51:51  来源:igfitidea点击:

Drawing routes on google maps

javascriptgoogle-mapsgoogle-maps-api-3

提问by Gandalf StormCrow

Is it possible to draw routes with google maps or any other map api? Like when you're looking for direction from point a to point b on google map with Get Directionsbutton.

是否可以使用谷歌地图或任何其他地图 api 绘制路线?就像你在谷歌地图上用Get Directions按钮寻找从 a 点到 b 点的方向一样。

I'd like to draw a line that follows certain road but without the directions I don't need those. And if I can draw multiple lines between multiple points on the map that would be awesome.

我想画一条沿着特定道路的线,但没有方向,我不需要那些。如果我能在地图上的多个点之间绘制多条线,那就太棒了。

Has anyone had experience with this before?

有没有人有过这方面的经验?

回答by aenariel

You can either use the Directions APIor, if you really prefer to ignore the directions Google generates, you can use the maps API drawing functionsto draw your own lines on the map.

您可以使用Directions API,或者,如果您真的更喜欢忽略 Google 生成的路线,您可以使用地图 API 绘图函数地图上绘制您自己的线条。

回答by tcltk-d

You can also employ "drawing library" https://developers.google.com/maps/documentation/javascript/drawing

您还可以使用“绘图库” https://developers.google.com/maps/documentation/javascript/drawing

But,this experimental tool cant specify colors nor line-thick via GUI. My enhanced example is at: http://members.jcom.home.ne.jp/tcltk-d/ge-navi.html(select "Drawing" view to draw)

但是,这个实验工具不能通过 GUI 指定颜色和线粗。我的增强示例位于:http: //members.jcom.home.ne.jp/tcltk-d/ge-navi.html(选择“绘图”视图进行绘制)