我似乎无法弄清楚这一点,我假设这是代码意图的问题?我有一个按钮,在 Leaflet 中单击应该会更改底图图层。
// Basemap Button - Left panel
L.Control.Watermark = L.Control.extend({
onAdd: function(map) {
var Basemap = L.DomUtil.create('img');
Basemap.src = 'basemap.png';
Basemap.style.width = '65px';
Basemap.style.top = '-90px';
Basemap.style.left = '10px';
Basemap.addEventListener('click', function() {
// Change the basemap layer of the map to the OpenStreetMap Street View layer
var osmStreetViewLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors'});
return Basemap;
},
});
L.control.watermark({ position: 'topleft' }).addTo(map);
问题似乎是关闭“});”
返回错误 });