我如何删除默认标记? [英] How do I remove default markers?

查看:95
本文介绍了我如何删除默认标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Google Map API V3,但我注意到这里有很多标记,尽管我不需要它们。例如,一些学校或其他地方InfoWindows出现时点击它们。

I'm using Google Map API V3 and I noticed there are a lot of markers which are here even though I don't need them. For examples, some schools or other places with InfoWindows appearing when clicking on them.

有什么办法可以删除它们,或者它不可能?

Is there any way I can remove them or is it just not possible?

推荐答案

应该在地图上显示的唯一标记是您自己添加的标记。小心分享你的代码或页面,我们可以看到发生这种情况?

The only markers that should show up on the map are those you add yourself. Care to share your code or a page where we can see this happening?

更新:好吧,这些不是正常意义上的'标记'他们只是感兴趣的点,它们的行为就像标记一样,你可以点击它们并看到infowindows。在我看来,这些可能是类 MapTypeStyleFeatureType ,可能是像poi.medical,poi.park,transit.station.rail等类型。我想知道你是否可以使用MapTypeStyle。也许是这样的:
$ b

Update: ok, these aren't really 'markers' in the normal sense of the word, they're just points of interest, which happen to behave like markers in that you can click on them and see infowindows. It seems to me that these might be of the class MapTypeStyleFeatureType, probably of types like poi.medical, poi.park, transit.station.rail and so on. I wonder if you could use the MapTypeStyle. Maybe something like this:

var myStyles =[
    {
        featureType: "poi",
        elementType: "labels",
        stylers: [
              { visibility: "off" }
        ]
    }
];

var myOptions = {
    zoom: 10,
    center: homeLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    styles: myStyles 
};

您可能还想看看风格地图向导

2016年7月更新:Maps API现在还有一个选项,您可以在MapOptions clickableIcons 中指定该选项,如果设置为false,则会出现这些POI的图标,但点击它们不会开放Google的infowindows。这可以节省您不必设置样式来隐藏图标,除非您想要,如果您只需要做的就是防止点击打开infowindows。
在初始化地图的选项中设置 clickableIcons:false

Update, July 2016: The Maps API also now has an option you can specify in the MapOptions, clickableIcons, which if you set to false, the icons for these POIs will appear but clicking them doesn't open Google's infowindows. This saves you having to set the styles to hide the icons unless you want to, if all you need to do is prevent the clicks opening the infowindows. Just set clickableIcons: false in the options you initialise the Map with.

这篇关于我如何删除默认标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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