question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layer.toGeoJson working but docs dont see

See original GitHub issue

Checklist

  • I’ve searched through the current issues to make sure this change hasn’t been suggested already.
  • I agree to follow the Code of Conduct that this project adheres to.

Which documents need updating?

https://leafletjs.com/reference.html#layer

Motivation

  map.value.on('pm:create', ({ shape, layer }) => {
    console.log('pm:create', layer.toGeoJSON())

and working but dont see docs and some TS(“@types/leaflet”: “^1.9.0”) dont add.

image

Suggested changes

I don’t know what to do, since I don’t know exactly what it is and I’m using TS.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Falke-Designcommented, Dec 6, 2022

@productdevbook you need to do a casting:

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

https://github.com/geoman-io/leaflet-geoman/discussions/949

1reaction
IvanSanchezcommented, Dec 6, 2022

The core Leaflet repo doesn’t handle typescript definitions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect TS typings · Issue #917 · geoman-io/leaflet ... - GitHub
I see that there are newly added typings for event handlers. For example, the layer is now L.Layer . Are you sure this...
Read more >
Export leaflet map to geojson - Stack Overflow
I want to store the markers, zoom & map center to load it later. There is plenty of ways to load geojson on...
Read more >
GeoJSON output returns 400 error when layer has M values
We had trouble exporting data from an ArcGIS service layer to GeoJSON format. Other formats (JSON, etc.) worked fine.
Read more >
[FEATURE-723] Perspective map GeoJSON doesn't accept style
Hi The perspective map JeoJSON property doersn't accept any style and I stuck with default blue color for all type of objects(point, ...
Read more >
Data Layer | Maps JavaScript API - Google Developers
// NOTE: This uses cross-domain XHR, and may not work on older browsers. map.data.loadGeoJson( "https://storage.googleapis ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found