在Google Map v2/v3中的路线上的特定距离上添加标记 [英] add marker on specific distance in route in google map v2/v3

查看:85
本文介绍了在Google Map v2/v3中的路线上的特定距离上添加标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个网页并使用google map v2/v3 javascript API创建以下功能...

I want to create a webpage and use google map v2/v3 javascript api to create folowing functionality...

我想在两个城市之间的预定义路线(没有直线)上添加一些标记.

I want to add some markers on predefined route (no straight line) between two cities.

此新标记应添加到用户提供的特定距离上.

this new marker should be added on specific distance provided by user.

我在网上搜索了很多东西,但是找不到演示或博客来演示这种类型的功能...

I searched lot online but i cant find a demo or blog to demonstrate this type of functionality...

如果有人已经通过此操作,请帮助我

please help me if anyone already went through this

推荐答案

首先,您肯定要使用自2010年5月起就已弃用的API 3,而不是API 2.

Firstly definitely you want to use API 3, not API 2, which has been deprecated since May 2010.

我认为您可以通过两种方式解决此问题.
一种方法是沿着路线绘制标记,并在每个标记之间绘制一条折线.这很容易设置,但基本上只会在标记之间绘制直线(或测地线弯曲).例如,如果要使路线实际沿着一条道路行驶,则需要绘制该道路所有曲折的标记点.

There's two ways I think you could tackle this.
One would be to plot your markers along the route, and draw a Polyline between each of them. This is simple to setup, but would basically just draw straight (or geodesic curved) lines between the markers. If you want the route to actually follow a road for instance, you'd need to plot marker points for all the twists and turns of that road.

另一种方法是使用DirectionsService渲染两个城市之间的路线,并使用Waypoints指定要在其间通过的标记.我认为这样会更好.

The other would be to use the DirectionsService to render the directions between your two cities, and use Waypoints to specify the markers in between that you want the directions to pass through. I think this would be better.

下面是一个例子: http://code.google.com/apis/maps /documentation/javascript/examples/directions-waypoints.html

这是有关如何构建它的Google教程: http://code.google.com/apis/maps/documentation /javascript/services.html#Waypoints

And here's the Google tutorial on how to build it: http://code.google.com/apis/maps/documentation/javascript/services.html#Waypoints

为了我的钱,最好的教程还是在Google网站上.

For my money, the best tutorials are on the Google site anyway.

这篇关于在Google Map v2/v3中的路线上的特定距离上添加标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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