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

Typescript incomplete definition 'pm:new|edit" event #1163

Closed
hoetmaaiers opened this issue May 11, 2022 · 1 comment
Closed

Typescript incomplete definition 'pm:new|edit" event #1163

hoetmaaiers opened this issue May 11, 2022 · 1 comment

Comments

@hoetmaaiers
Copy link
Contributor

Could it be that I found some incomplete Typescript definition?
The pm:create and pm:edit events have a layer property. This layer should have a toGeoJSON function available?

 map.on("pm:create", (event) => {
  setMarker(event.layer.toGeoJSON());
});
@hoetmaaiers hoetmaaiers changed the title Typescript incomplete definition? Typescript incomplete definition 'pm:new|edit" event May 11, 2022
@Falke-Design
Copy link
Collaborator

Duplicate of #945

You need to cast the layer:

map.on("pm:create", (e) => {
  if(e.shape === 'Polygon'){
     (e.layer as Polygon).toGeoJSON();
  }
}

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

2 participants