Google Maps Version 3删除路线标记 [英] Google Maps Version 3 Remove directions markers

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

问题描述

有什么方法可以删除路线在地图上放置的标记?我在地图上显示了4个位置.用户所在的绿色箭头和标记为A,B,C的3个位置.如果我单击一个,它将在用户位置和标记之间路由.问题是Google添加了一个新的A& B标记到地图上,作为路线的起点和终点.现在我在地图上有几个A和B标记,这很令人困惑.

Is there any way to remove the markers that the directions put on the map? I have 4 locations that show on the map. A green arrow where the user is and 3 locations marked A, B, C. If I click on one it routes between the user's location and the marker. The problem is that google adds a new A & B marker to the map as the start and end of the directions. Now I have a couple A and B markers on the map and it's pretty confusing.

谢谢

推荐答案

不确定这是否有帮助.创建新的GDirection并为其提供地图对象时,一旦加载方向,它将自动将多段线绘制到地图上.这还将在旅程的开始和结束时自动添加标记.

Not sure if this is helpful or not. When you create a new GDirection and supply it with a map object, it will automatically draw the polyline to the map as soon as the direction is loaded. This also automatically adds the markers at the start and end of the journey.

但是,我注意到,如果您最初没有提供地图对象,而是使用加载"事件侦听器将折线手动添加到地图,则会得到该线,而不是标记. /p>

I've noticed, however, that if you don't supply the map object initially and instead use the the 'load' event listener to manually add the polyline to the map, you get the line but not the markers.

//Don't supply a map to GDirections()
var direction = new GDirections(); 

//Make sure {getPolyline:true} is given to the load function
direction.load("here to there", {getPolyline:true});

GEvent.addListener(direction, 
                   "load", 
                   function(){ map.addOverlay(direction.getPolyline()); }
);

与查找和删除标记相比,这可能更容易,尤其是如果您仍在使用"load"事件监听器的话.

This might be easier than finding and removing the markers, especially if you're using the 'load' event listener anyway.

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

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