Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Typescript casting of event payload #1014

Open
Falke-Design opened this issue Oct 19, 2021 · 0 comments
Open

Document Typescript casting of event payload #1014

Falke-Design opened this issue Oct 19, 2021 · 0 comments

Comments

@Falke-Design
Copy link
Collaborator

Falke-Design commented Oct 19, 2021

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant