Leaflet 传单画布标记不能设置笔划

Leaflet 传单画布标记不能设置笔划,leaflet,Leaflet,正在扩展L.circleMarker 因此,可以将行程设置为L.canvasMarker(?) 有人知道我做错了什么,或者我需要在传单画布标记包中做什么更改才能使其正常工作吗 这是一个JSFIDLE;点击圆圈标记器,它得到一个更粗的笔划。但是如果你点击画布标记,它什么也得不到 将\u updateImg(层)功能更改为: _updateImg(layer) { const { img } = layer.options; const p = la

正在扩展L.circleMarker

因此,可以将行程设置为L.canvasMarker(?)

有人知道我做错了什么,或者我需要在传单画布标记包中做什么更改才能使其正常工作吗

这是一个JSFIDLE;点击圆圈标记器,它得到一个更粗的笔划。但是如果你点击画布标记,它什么也得不到


\u updateImg(层)
功能更改为:

_updateImg(layer) {
            const { img } = layer.options;
            const p = layer._point.round();
            p.x += img.offset.x; p.y += img.offset.y;
            if (img.rotate) {
                this._ctx.save();
                this._ctx.translate(p.x, p.y);
                this._ctx.rotate(img.rotate * Math.PI / 180);
                this._ctx.drawImage(img.el, -img.size[0] / 2, -img.size[1] / 2, img.size[0], img.size[1]);
                this._ctx.restore();
            } else {
              if(layer.options.stroke && layer.options.weight > 0){
                this._ctx.strokeStyle = layer.options.color; 
                this._ctx.lineWidth = layer.options.weight;    
              }
              this._ctx.drawImage(img.el, p.x - img.size[0] / 2, p.y - img.size[1] / 2, img.size[0], img.size[1]);
              if(layer.options.stroke && layer.options.weight > 0){
                this._ctx.strokeRect(p.x - img.size[0] / 2, p.y - img.size[1] / 2, img.size[0], img.size[1]);
              }
            }
        }
如果您不想让它与
rotate
一起工作,则必须将其复制到上面的块中。 它在图像后面添加了一个带有笔划的矩形

另外,不要忘记向图像中添加
weight:0
,因为圆圈标记器的默认笔划为3

    let marker1 = L.canvasMarker([58.970471,5.730373], {
      radius: 15,
      img: {
        url: 'https://register.geonorge.no/symbol/files/tilgjengelighet/sittegruppe_positiv_groenn.png',
        size: [30,30]
      },
      weight: 0
    }).addTo(map);

示例:

谢谢!geoman也能很好地工作:D唯一的问题是捕捉,这并不太糟糕
    let marker1 = L.canvasMarker([58.970471,5.730373], {
      radius: 15,
      img: {
        url: 'https://register.geonorge.no/symbol/files/tilgjengelighet/sittegruppe_positiv_groenn.png',
        size: [30,30]
      },
      weight: 0
    }).addTo(map);