如何删除默认标记?

发布于 2024-12-06 10:09:39 字数 109 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黒涩兲箜 2024-12-13 10:09:40

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

更新:好吧,这些并不是真正意义上的“标记”,它们只是兴趣点,它们的行为恰好像标记,您可以单击它们并查看信息窗口。在我看来,这些可能属于 MapTypeStyleFeatureType,可能是 poi.medical、poi.park、transit.station.rail 等类型。我想知道您是否可以使用 MapTypeStyle。也许是这样的:

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

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

您可能还想查看样式化地图向导

更新,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:

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

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

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.

失而复得 2024-12-13 10:09:40

您可以查看自定义样式地图

还有一个向导可以帮助构建选项数组。

You might have a look at custom styled maps.

There is also a wizard that helps to build the options array.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文