Currently, I am incorporating leaflet, leaflet-editable, and Angular into a project. My goal is to develop controls that allow for drawing a multi polygon on the map, similar to the example showcased on the GitHub page. The code in my component is structured as follows:
import 'leaflet';
import 'leaflet-editable';
...
this.map = L.map('map', {editable: true}).setView([-0.163360, 13.053125], 3).addLayer(osm);
L.NewPolygonControl = L.Control.extend({
options: {
position: 'topleft'
},
// rest of the control implementation
});
L.AddPolygonShapeControl = L.Control.extend({
options: {
position: 'topleft'
},
// more of the control implementation
});
this.map.addControl(new L.NewPolygonControl());
this.map.addControl(new L.AddPolygonShapeControl());
Despite the controls functioning correctly, an error message appears post-compile containing the following details:
ERROR in src/app/pages/countryEdit/country/country.component.ts(84,7):
error TS2339: Property 'NewPolygonControl' does not exist on type
'typeof L'.
src/app/pages/countryEdit/country/country.component.ts(110,7): error
TS2339: Property 'AddPolygonShapeControl' does not exist on type
'typeof L'.
src/app/pages/countryEdit/country/country.component.ts(134,31): error
TS2339: Property 'NewPolygonControl' does not exist on type 'typeof
L'.
src/app/pages/countryEdit/country/country.component.ts(135,31): error
TS2339: Property 'AddPolygonShapeControl' does not exist on type
'typeof L'.
As my expertise with Angular and TypeScript are still growing, solving this compile issue proves challenging. I have included types for leaflet and leaflet-editable but the error persists.