沿路线添加标记 [英] Add Markers Along a Route

查看:168
本文介绍了沿路线添加标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Google地图方向沿路线创建多个标记。我已经将航路点作为一个选项进行了研究,但基于我对它的文档的理解,它创建了从A点到B点的路线,并通过了您设置的路点以便从A点到B点。不希望我的路线根据预定的航点进行计算。我需要一个预定的起点和终点,并根据地图上的距离计算我的航点。例如,在路线上每隔几英里创建一个标记。航点是否会这样做?如果是这样,任何已经完成的地方的例子?



有什么建议? 正如安德鲁告诉航点不会这样做。



您没有预定义的路线点(例如eaxmple),所以您可以做的是:

一个方向由route-> overview_path定义的点组成,它定义了该路线的多段线。



所以你可以走这条路,计算两条路径之间的距离使用 google .maps.geometry.spherical.computeDistanceBetween() ,并在达到所需距离时创建标记。



这里是该建议的实施: http://jsfiddle.net/doktormolle/eNzFb/






< edit>



请注意:此答案已过时。您最好使用内置的 IconSequence 代替。


I am trying to create several markers along a route from google maps directions. I have already looked into waypoints as an option but based on my understanding of the documentation on it, it creates the route from point A to point B and passes through the waypoints that you set in order to get from point A to point B. I don't want my route to be calculated based on predetermined waypoints. I want a predetermined start and end point, with my waypoints calculated based on a distance on the map. For instance, a marker created every so many miles along the route. Would waypoints do this? If so, any examples of where that has been done?

Any suggestions?

解决方案

As Andrew told waypoints wouldn't do it.

You don't have predefined points for the route(like the eaxmple), so what you can do is:

A direction consists of points defined by route->overview_path, what defines the polyline for the route.

So you may walk this path, calculate the distance between two path-points using google.maps.geometry.spherical.computeDistanceBetween() and create the marker when the desired distance has been reached.

Here is an implementation of the suggestion: http://jsfiddle.net/doktormolle/eNzFb/


<edit>

Please Note: this answer is obsolete. You better use the built-in IconSequence instead.

这篇关于沿路线添加标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆