You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am needing to draw a rectangle on the map without having to press a button. I'm having difficulty figuring out how to put the map into drawing mode without the button. I've tried based on examples from leaflet-draw, but nothing seems to be working for me. Is there a way to enable the drawing mode to add a rectangle programatically?
The text was updated successfully, but these errors were encountered:
I have tried this based on other issues here, but I keep getting an error.
setRectmode(){
var self = this;
var shapeOptions = {
stroke: true,
color: '#f06eaa',
weight: 4,
opacity: 0.5,
fill: true,
fillColor: null, //same as color by default
fillOpacity: 0.2,
clickable: true,
editable: true
};
var rectDraw = new (L as any).Draw.Rectangle(self.map, shapeOptions); <<<error here
rectDraw.enable();
this.drawnItems.addLayer(rectDraw);
}
ERROR TypeError: Cannot read property 'Rectangle' of undefined
I've also tried changing the line where the error occurs to this
var rectDraw = new (L as any).Rectangle(self.map, shapeOptions);
ERROR TypeError: Cannot read property 'lat' of undefined
Any pointers as to what I might be doing wrong? The goal is to put the map into a mode where I can draw a rectangle on the map.
I am needing to draw a rectangle on the map without having to press a button. I'm having difficulty figuring out how to put the map into drawing mode without the button. I've tried based on examples from leaflet-draw, but nothing seems to be working for me. Is there a way to enable the drawing mode to add a rectangle programatically?
The text was updated successfully, but these errors were encountered: