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

How to remove MapBox logo from bottom left corner?

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

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

这会生成如下地图: http://s4.postimg.org/58m4aeb8d/mapbox.png

如何删除左下角的 "Mapbox" 徽标?

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

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

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

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

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

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

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

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

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

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

我发现这个解决方案可以保留 mapbox 文字标记(=徽标)和文本属性,但不会干扰界面的其余部分。

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

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

这对我有用:

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

在style.css中粘贴此代码

.mapbox-logo{ display: none; } .mapboxgl-ctrl-logo { display: none !important; } .mapbox-improve-map { display: none; } .mapboxgl-ctrl-compass { display: none; }

是javascript文件添加这个..

const map = new mapboxgl.Map({ container: this.mapContainer, style: 'mapbox://styles/mapbox/dark-v10', center: [this.state.lng, this.state.lat], zoom: this.state.zoom, attributionControl: false });

它可以帮助您隐藏服务条款

在为 map

创建对象时只需添加 attributionControl: false
const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11',
    attributionControl: false
});

你可以试试这个

@IBOutlet weak var mapView: MGLMapView!{
        didSet{
            mapView.styleURL = URL(string: "mapbox://styles/mapbox/dark-v10")
            mapView.attributionButton.alpha = 0 // to remove info icon on right
            mapView.logoView.isHidden = true // to remove mapBox logo on left
            mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        }
    }

如果您使用的是 Mapbox Static Images API,您可以通过将以下参数添加到您的来源 URL:

来轻松删除 Mapbox 徽标和 OpenStreetMaps 属性
&attribution=false&logo=false

示例(将 xxx 替换为您自己的访问令牌):

https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/-122.385,37.7175,12,0/300x300?access_token=xxx

请记住,法律仍然要求您 include proper attribution 网页或文档中的其他地方。

The Mapbox logo is a small image containing the stylized word "Mapbox". It typically resides on the bottom left corner of a map. While you may move the logo to a different corner of the map, we require the Mapbox logo to appear on our maps so that Mapbox and its maps get proper credit.

https://docs.mapbox.com/help/getting-started/attribution/