尝试在 JavaScript 中创建地图时传递 attributionControl: false,然后向地图添加新的属性控件,然后使用 Leaflet URL 调用 setPrefix 方法,最后在地图上加载图块图层:
var map = L.map('map', {attributionControl: false}).setView([51.505, -0.09], 13);
var myAttrControl = L.control.attribution().addTo(map);
myAttrControl.setPrefix('<a href="https://leafletjs.com/">Leaflet</a>');
const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: 'Data by © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, under <a href="https://opendatacommons.org/licenses/odbl/">ODbL.</a>'
}).addTo(map);
地图看起来和以前一样,但旗帜会消失: