如何将自定义属性添加到默认的 mapbox-gl 属性控件?

How do I add custom attribution to the default mapbox-gl attribution control?

归因控制:真

什么都不做。我需要在哪里放置 mapbox-gl 样式的属性,以便它显示在控件中?

此功能尚未实现。它非常失踪。你会考虑提交 PR 吗? https://github.com/mapbox/mapbox-gl-js/issues/1485

您还可以使用 HTML/CSS + Mapbox CSS 样式,通过使用 mapboxgl-ctrl-attrib 类 (example):

<div id="map">
    <!-- Modify the style: right position so it matches with the mapbox attribution -->
    <div id="attribution" class="mapboxgl-ctrl mapboxgl-ctrl-attrib mapboxgl-ctrl-bottom-right" style="position: fixed; bottom: 0; right: 230px;">
        <a href="*">Attribution 1</a> &nbsp;|&nbsp; 
        <a href="*">Attribution 2</a>  &nbsp;|&nbsp;
        <a href="*">Attribution n</a> &nbsp;|
    </div>
</div>

对于那些仍然对此感到疑惑的人。如 Mapbox issue #1485.

中所述,Mapbox 对此做了一个很好的解决方法

我只是复制了一个Mapbox合作者提供的解决方案:

map.addSource('attribution', {
type: 'geojson',
data: {
  type: 'FeatureCollection',
  features: []
},
attribution: 'Your custom attribution'
});