在传单的 DOM 中添加按钮功能

问题描述 投票:0回答:0

我似乎无法弄清楚这一点,我假设这是代码意图的问题?我有一个按钮,在 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 &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors'});

      return Basemap;
  },
});

L.control.watermark({ position: 'topleft' }).addTo(map);

问题似乎是关闭“});”

返回错误 });

javascript dom leaflet
© www.soinside.com 2019 - 2024. All rights reserved.