如何删除默认标记?
我正在使用 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
地图上唯一应显示的标记是您自己添加的标记。愿意分享您的代码或我们可以看到这种情况发生的页面吗?
更新:好吧,这些并不是真正意义上的“标记”,它们只是兴趣点,它们的行为恰好像标记,您可以单击它们并查看信息窗口。在我看来,这些可能属于 MapTypeStyleFeatureType,可能是 poi.medical、poi.park、transit.station.rail 等类型。我想知道您是否可以使用 MapTypeStyle。也许是这样的:
您可能还想查看样式化地图向导
更新,2016 年 7 月:地图 API现在还有一个您可以在 MapOptions 中指定的选项
clickableIcons
,如果您将其设置为 false,则会显示这些 POI 的图标,但单击它们不会打开 Google 的信息窗口。如果您需要做的只是阻止点击打开信息窗口,那么您就不必设置隐藏图标的样式,除非您愿意。只需在初始化地图的选项中设置
clickableIcons: false
即可。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?
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:
You might also want to look at the Styled Map Wizard
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.您可以查看自定义样式地图。
还有一个向导可以帮助构建选项数组。
You might have a look at custom styled maps.
There is also a wizard that helps to build the options array.