Add Markers Along a Route

后端 未结 3 1031
渐次进展
渐次进展 2020-12-16 08:45

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 docum

3条回答
  •  被撕碎了的回忆
    2020-12-16 09:24

    As Andrew told waypoints wouldn't do it.

    You don't have predefined points for the route (like the example), 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/


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

提交回复
热议问题