Conceptual question on the relationship between Geoman and L.geoJSON #1338
-
Very impressed with Geoman and the detailed documentation, but without an introductory project or overview, it's a little opaque for me in terms of how it interacts with Leaflet, particularly in the area of layer data management. Can Geoman directly edit a geoJSON layer? The documentation states:
What does "only work correctly" mean here? What can it do? I've managed to move a Geoman drawn shape to L.GeoJSON as follows:
Will Geoman directly edit items on that L.GeoJSON layer, or do I need to move them back to a Geoman native layer to edit them (then back to L.GeoJSON again once done editing)? Is there a way to have Geoman just automatically use only geoJSON for data/layer management, or are there always steps to shuttle the data between L.GeoJSON and a Geoman layer? I guess put another way, can a geoJSON layer also be a Geoman layer? I just discovered that the geoman.io source code contains these two functions that would imply data has to be shuttled manually between geoman layers and geoJSON. Anyone have more freestanding code that will do this?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Geoman is a plugin for Leaflet, and Leaflet is managing all the data on the map. Here is how GeoJSON works with Leaflet / Geoman:
What I want to say with that, GeoJSON is only a String and only used to store data outside of the Leaflet world for example in a database. To modify data, they need to be imported / converted to a Leaflet-Layer / JavaScript-Object and if you want to store the data in a database, you need to export the Leaflet-Layer as GeoJSON. Checkout this example: https://jsfiddle.net/fd1ehwk2/1/ |
Beta Was this translation helpful? Give feedback.
Geoman is a plugin for Leaflet, and Leaflet is managing all the data on the map.
Here is how GeoJSON works with Leaflet / Geoman:
const geojson = {"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[72.881536,19.045568],[72.881536,19.06374],[72.909676,19.06374],[72.909676,19.045568],[72.881536,19.045568]]]}}]}
const geoGroup = L.geoJSON(geojson)
.