如何隐藏或禁用谷歌地图 JavaScript API v3 上的谷歌徽标、页脚、版权?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12499886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to hide or disable the google logo, footer, copyright on google maps JavaScript API v3?
提问by mkhuete
I have this assignment at work in which I need to use the Google maps API v3 and the design they gave me was without the logo/footer/copyright that google puts in the inferior part of the map. Well, I need to have it disabled or hidden because I was told that I need to match the exact design no matter what.
我在工作中有这个任务,我需要使用谷歌地图 API v3,他们给我的设计没有谷歌放在地图下部的徽标/页脚/版权。好吧,我需要禁用或隐藏它,因为有人告诉我无论如何我都需要匹配确切的设计。
I had to emphasize that by doing this I breach the terms of use of Google service...
我不得不强调,这样做我违反了 Google 服务的使用条款......
9.4 Attribution.
(a) Content provided to you through the Service may contain the trade names, trademarks, service marks, logos, domain names, and other distinctive brand features of Google, its partners, or other third party rights holders of content indexed by Google. When Google provides this attribution, you must display it as provided through the Service or as described in the Maps APIs Documentation and may not delete or in any manner alter these trade names, trademarks, service marks, logos, domain names, and other distinctive brand features. https://developers.google.com/maps/terms
9.4 归属。
(a) 通过服务提供给您的内容可能包含 Google、其合作伙伴或其他第三方权利持有人的商品名称、商标、服务标记、徽标、域名和其他由 Google 编制索引的内容的独特品牌特征。当 Google 提供此属性时,您必须按照服务提供的内容或 Maps API 文档中的描述显示它,并且不得删除或以任何方式更改这些商品名称、商标、服务标记、徽标、域名和其他独特品牌特征。 https://developers.google.com/maps/terms
Well at my work they didn't care about that and they always told me to do it anyway so these is how I'm doing it.
好吧,在我的工作中,他们并不关心这一点,他们总是告诉我无论如何都要这样做,所以我就是这样做的。
In the css I added the following lines of code:
在 css 中,我添加了以下代码行:
#map-report div.gmnoprint,
#map-report div.gmnoscreen {
display: none;
}
img[src="http://maps.gstatic.com/mapfiles/google_white.png"] {
display: none;
}
回答by Abhishek Goel
This CSS works like charm [October 2019 tested].
Removes Google Logo, terms of use, and Report a problemdiv.
这个 CSS 就像魅力一样 [2019 年 10 月测试]。
删除Google 徽标、使用条款和报告问题div。
a[href^="http://maps.google.com/maps"]{display:none !important}
a[href^="https://maps.google.com/maps"]{display:none !important}
.gmnoprint a, .gmnoprint span, .gm-style-cc {
display:none;
}
.gmnoprint div {
background:none !important;
}
回答by Luis A. Florit
Try this for api v3:
为 api v3 试试这个:
.gm-style-cc { display:none; }
.gm-style-cc { display:none; }
回答by Max Flex
Jan 2018 update. Leaves only clean map:
2018 年 1 月更新。只留下干净的地图:
a[href^="http://maps.google.com/maps"],
a[href^="https://maps.google.com/maps"],
a[href^="https://www.google.com/maps"] {
display: none !important;
}
.gm-bundled-control .gmnoprint {
display: block;
}
.gmnoprint:not(.gm-bundled-control) {
display: none;
}
As of Feb 2018 the CSS above makes markers on the map unclickabe. If you don't have any markers you shoudn't have any problems, but if you do just remove the last CSS rule .gmnoprint:not(.gm-bundled-control)
, the markers will become clickable but there will be some little copyright and terms of use labels
截至 2018 年 2 月,上面的 CSS 使地图上的标记 unclickabe。如果你没有任何标记,你应该没有任何问题,但如果你只是删除最后一个 CSS 规则.gmnoprint:not(.gm-bundled-control)
,标记将变得可点击,但会有一些版权和使用条款标签
回答by kaskader
As you mentioned, removing the Google logo and copyright notices is not compliant with the Google Maps APIs TOS, specifically with paragraph 9.4:
正如您所提到的,删除 Google 徽标和版权声明不符合Google Maps API TOS,特别是第 9.4 段:
"Content provided to you through the Service may contain the Brand Features of Google, its strategic partners, or other third-party rights holders of content that Google indexes. When Google provides those Brand Features or other attribution through the Service, you must display such attribution as provided (or as described in the Maps APIs Documentation) and must not delete or alter the attribution.".
“通过服务提供给您的内容可能包含 Google、其战略合作伙伴或 Google 索引内容的其他第三方权利持有者的品牌特征。当 Google 通过服务提供这些品牌特征或其他归属时,您必须显示此类提供的署名(或 Maps API 文档中的描述),不得删除或更改署名。” .
To be compliant with Terms of Service please always make sure the Google logo and copyright notices are visible.
为了遵守服务条款,请始终确保 Google 徽标和版权声明可见。
回答by Lukas Liesis
Works like a charm with v3:
使用 v3 就像一个魅力:
.gm-style-cc {
display: none !important;
}
.gm-style a[href^="https://maps.google.com/maps"] {
display: none !important;
}
Take a note for 2nd selector I use .gm-style
before a
because otherwise it will hide alllinks to https://maps.google.com/maps
not only from google map itself.
记下我.gm-style
之前使用的第二个选择器a
,否则它会隐藏所有链接,https://maps.google.com/maps
而不仅仅是来自谷歌地图本身。
回答by ????? ???
You can't remove it from API. But you can use a div which you can place on the copyright notice
你不能从 API 中删除它。但是您可以使用可以放在版权声明上的 div
<div style="width:100px; height:15px; position:absolute; margin-left:100px margin-
bottom:50px; background-color:white;">
</div>
do the changes to height,width and margins according to need.
根据需要对高度、宽度和边距进行更改。
回答by Guillaume
You can do this:
你可以这样做:
#map-report a img { display:none; }
回答by Yuvaraj
You can prevent the click on google copyright.so, that it will not let user to move out of your applicaiton.Hope this resolves your problem.
您可以阻止点击 google 版权。因此,它不会让用户移出您的应用程序。希望这可以解决您的问题。
google.maps.event.addListenerOnce(map, 'idle', function(){
// do something only the first time the map is loaded
//@mapCopyright - gets the google copyright tags
var mapCopyright=document.getElementById('map-canvas').getElementsByTagName("a");
$(mapCopyright).click(function(){
return false;
});
});
回答by curved
First put your maps in a container :
首先将您的地图放入容器中:
<div id="map">
<div class="google-maps"></div>
</div>
CSS:
CSS:
#map {
position: relative;
height: 500px;
overflow: hidden; //important
}
#map .google-maps {
position: absolute;
width: 100%;
height: 110%; //that will do the trick
left: 0;
top: 0;
}
回答by eyal_katz
Improving on another solution here, this just disables the links in the map, so people don't leave the app (and get stuck without a way to go back). On an app it makes a big difference when people try to scroll a small map and tap by mistake.
改进这里的另一个解决方案,这只会禁用地图中的链接,因此人们不会离开应用程序(并且卡住而无法返回)。在应用程序中,当人们尝试滚动小地图并错误点击时,会产生很大的不同。
google.maps.event.addListenerOnce(map, 'idle', function(){
$("#map a").click(function(){
return false;
});
});