skeate/Leaflet.buffer

Buffer load size.

JonathanWilkins opened this issue · 2 comments

Is it possible to programmatically create a default buffer of a given size?
Without having to first click on a shape and drag it.

Thanks

Not at present. I'm not 100% sure what sort of implementation you mean, but a good place to start might be here: https://github.com/skeate/Leaflet.buffer/blob/master/src/leaflet.buffer.js#L302

Do you mean start at a particular buffer radius when they click? Or do you mean some way to just call a function (so you could have an external button that says, say, "set buffer to 5m") to buffer a particular layer?

Yeah thats what I am trying to do. Evetually figured it out.
This is what I did.

  line.addTo(zoneService.editLayer);
 zoneService.drawBufferControl._toolbars.edit._modes.buffer.handler.enable();
 let l = {
            layer: line,
            latlng: new L.LatLng(line.getBounds().getNorth(), line.getBounds().getCenter().lng )
   }
  zoneService.drawBufferControl._toolbars.edit._modes.buffer.handler._onLayerDragStart(l);
        
 let distanceFromCenter = {
         // used  "leaflet-geometryutil" to get distance from a lat lng postition.
         latlng: L.GeometryUtil.destination(l.latlng, 0, this.bufferSize.val())
  };
            zoneService.drawBufferControl._toolbars.edit._modes.buffer.handler._onLayerDrag(distanceFromCenter);
zoneService.drawBufferControl._toolbars.edit._modes.buffer.handler._onLayerDragEnd();```