简体   繁体   English

如何在Google地图(V3)中为我的折线创建方向箭头?

[英]How to create direction arrows for my polylines in Google Maps (V3)?

I have routes as Google Maps Polylines in my project (an example, http://rutasgdl.com/rutas/626-2 ) and I want to add direction arrows to the routes. 我的项目中有Google Maps Polylines的路线(例如http://rutasgdl.com/rutas/626-2 ),我想在路线上添加方向箭头。 I want something like this (sadly, it is for Google Maps V2) http://wtp2.appspot.com/ArrowLine.htm 我想要这样的东西(遗憾的是,它适用于谷歌地图V2) http://wtp2.appspot.com/ArrowLine.htm

Can you point me in the right direction in order to achieve this? 为了达到这个目的,你能指出我正确的方向吗? Regards. 问候。

The Google Maps API now supports this natively (as of July 2012). Google Maps API现在支持此功能(截至2012年7月)。

https://developers.google.com/maps/documentation/javascript/symbols#add_to_polyline https://developers.google.com/maps/documentation/javascript/symbols#add_to_polyline

I found a blog entry by Pavel Zotov, where he describes a way to add arrows to a polyline. 我在Pavel Zotov找到了一篇博客文章,他描述了一种向折线添加箭头的方法。 The trick is to extend google.maps.OverlayView. 诀窍是扩展google.maps.OverlayView。

http://yab.hot-line.su/javascript/polyline-with-arrows-in-google-maps-api-v3.html http://yab.hot-line.su/javascript/polyline-with-arrows-in-google-maps-api-v3.html

(I don't know if I can reproduce the code here, so I only post a link to the blog entry.) (我不知道我是否可以在这里重现代码,所以我只发布一个链接到博客条目。)

Here is the code from Bill Chadwick ported to v3 这是Bill Chadwick移植到v3的代码

Enjoy! 请享用!

https://docs.google.com/open?id=0B4WFC4iBvLilOHc1YTFnakFsdWM https://docs.google.com/open?id=0B4WFC4iBvLilOHc1YTFnakFsdWM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM