Google Maps API v3删除“点击以在Google地图上查看此区域”链接 [英] Google Maps API v3 Remove "Click to see this area on Google Maps" link

查看:164
本文介绍了Google Maps API v3删除“点击以在Google地图上查看此区域”链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,Google地图API ToS会移除覆盖在地图底部的Google品牌信息或ToS链接,但我使用maps API来显示视频游戏地图,而且Google徽标链接到主要Google地图网站,它会将您发送到与我的游戏内地图的当前视图相同的世界坐标的真实世界地图,这对此用例完全没有意义。有任何方法可以停用Google地图的连结(点击Google标志)吗?我看过去除标志的CSS示例,但链接仍然存在。我甚至不关心有标志,为了ToS,我宁愿留在那里,但是有什么办法禁用链接?

I know that it is against the Google Maps API ToS to remove the Google branding or the ToS link that are overlaid across the bottom of the map, but I'm using the maps API to display a video game map, and the Google logo links to the main Google Maps site in such a way that it sends you to a real-world map at the same world coordinates as the current view of my in-game map, which completely doesn't make sense for this use case. Is there any way to disable the link to Google Maps from clicking on the Google logo? I've seen CSS examples for removing the logo, but the link remains. I don't even care about having the logo, and for the sake of the ToS, I'd prefer to leave it there, but is there any way to disable the link?

推荐答案

在加载地图后,您可以使用JavaScript使链接不做任何操作:

You could always use JavaScript to make the link do nothing after the map has loaded:

var anchors = document.getElementsByTagName('a'),
    l = anchors.length,
    i,
    a;

for (i = 0; i < l; i++) {
    a = anchors[i];
    if (a.href.indexOf('maps.google.com/maps?') !== -1) {
         a.title = ''; 
         a.onclick = function () { return false; };
    }
}

您可能必须在地图上重做(缓存锚标记,因此您不必每次都搜索它)。

You'd probably have to redo this when the map is changed (cache the anchor tag so you don't have to search for it each time).

这篇关于Google Maps API v3删除“点击以在Google地图上查看此区域”链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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