geoman-io/leaflet-geoman
Document Typescript casting of event payload
Aperta
#1014 aperta il 19 ott 2021
good first issuehelp wantedimprovementtypescript
Metriche repository
- Star
- (1933 stelle)
- Metriche merge PR
- (Merge medio 9g 6h) (5 PR mergiate in 30 g)
Descrizione
In the event payload the return type of layer is `L.Layer? so it needs to be casted to the Layer-Type.
layer.on('pm:edit', (e) => {
if(e.shape === 'Polygon'){
(e.layer as Polygon).getLatLngs();
}
});
I think following should work too: (But not tested)
layer.on('pm:edit', (e) => {
if(e.layer instanceof L.Polygon){
(e.layer as Polygon).getLatLngs();
}
});
This should documented in the Readme
Explainations: