javascript 如何从左下角删除 MapBox 徽标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30320079/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 12:02:29  来源:igfitidea点击:

How to remove MapBox logo from bottom left corner?

javascriptmapbox

提问by lateo

I'm embeding a MapBox map in my html page via mapbox.js script like so:

我通过 mapbox.js 脚本在我的 html 页面中嵌入 MapBox 地图,如下所示:

L.mapbox.accessToken = 'pk.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxx';
var map = L.mapbox.map('map', 'xxxxx.xxxxxxxx', {
    zoomControl: false
});

This produces a map like this: http://s4.postimg.org/58m4aeb8d/mapbox.png

这会产生一个这样的地图:http: //s4.postimg.org/58m4aeb8d/mapbox.png

How do I remove "Mapbox" logo in the bottom left corner?

如何删除左下角的“Mapbox”标志?

回答by Dave

You can only completely remove the attribution on maps that do not contain Mapbox (Streets, Terrain, Satellite) or OpenStreetMap layers. This is because the OpenStreetMap and DigitalGlobe data contained in these layers legally require attribution.

您只能在不包含 Mapbox(街道、地形、卫星)或 OpenStreetMap 图层的地图上完全删除属性。这是因为这些图层中包含的 OpenStreetMap 和 DigitalGlobe 数据在法律上需要归属。

If your map doesn't include these layers, you can remove the default attribution by setting the info control to false:

如果您的地图不包含这些图层,您可以通过将信息控件设置为 false 来删除默认属性:

var map = L.mapbox.map('map', 'examples.map-8ced9urs', {attributionControl: false});

You can add your own attribution by using the L.control.attribution constructor.

您可以使用 L.control.attribution 构造函数添加自己的属性。

var credits = L.control.attribution().addTo(map);
credits.addAttribution('Credits: Penny Dog Mapping Co.');

You can, however, move the attribution. If you are using a layer that requires attribution, but want to move it to a different part of the page, you can insert this HTML snippet elsewhere on the page, like a page footer:

但是,您可以移动归因。如果您使用的图层需要归因,但想将其移动到页面的不同部分,则可以在页面的其他位置插入此 HTML 代码段,例如页面页脚:

<a href='https://www.mapbox.com/about/maps/' target='_blank'>Maps &copy; Mapbox &copy; OpenStreetMap</a>

回答by max kaplan

This may violate the MapBox terms of service. Adding this css will remove it...

这可能违反 MapBox 服务条款。添加此 css 将删除它...

.mapbox-logo{
    display: none !important;
}

回答by extols

As per https://www.mapbox.com/plans/. Unless you are on the Standard or Premium pricing plans then the MapBox logo is required according to the terms of service.

根据https://www.mapbox.com/plans/。除非您使用标准或高级定价计划,否则根据服务条款需要 MapBox 徽标。

回答by Nico Van Belle

I've found this solution which keeps the mapbox wordmark(=logo) and text attributions in place but keeps them from interfering with the rest of the interface.

我找到了这个解决方案,它可以将 mapbox wordmark(=logo) 和文本属性保留在适当的位置,但不会干扰界面的其余部分。

This solution does NOT violate the terms of service!

此解决方案不违反服务条款!

.leaflet-bottom, .leaflet-top {
    z-index: 0 !important; // This is 1000 by default
    position: absolute;
    pointer-events: none;
}

回答by Guilherme Patriarca

This worked for me:

这对我有用:

.mapboxgl-ctrl-logo {
    display: none !important;
}