5

I have a geojson file and I get it with ajax. but I want to prevent the editing of the geometries I load during startup. Only the ones that are added with leaflet.pm should be editable. How can i do it ?

leaflet.pm

I'm using geojson coordinate json. these drawings are added to the map when the page loads.

{pmIgnored: true} after trying to delete delete mode when I click on one of the static drawings I added from geojson deletes all of them. How can I prevent it?

var geojsonData;
// addded geojson ajax
$.getJSON("geo.json", {
  async: false,
}, function (data) {
  geojsonData = L.geoJson(data, {
    pmIgnore: true, // ignore static shaped edited
    style: {
      weight: 20
    },
  }).addTo(map);
});

what I want to do is not to delete static coordinates in any way when deletion mode is turned on

Falke Design
  • 10,635
  • 3
  • 15
  • 30
vciloglu
  • 526
  • 2
  • 7
  • 19

2 Answers2

3

Apply the pmIgnore option not to the group, but to each individual leaflet layer. Do this with the style and pointToLayer options of L.GeoJSON, e.g.:

  geojsonData = L.geoJson(data, {
    style: {
      pmIgnore: true,
      weight: 20
    },
  })
IvanSanchez
  • 18,272
  • 3
  • 30
  • 45
  • Thank you! This worked perfectly. I was trying to figure out how to add it to an individual layer and didn't realize I could do it this way. – trevorp Jul 19 '22 at 16:24
2

I'm Sumit, the maintainer of leaflet.pm

I think there was a bug regarding ignoring of layers through pmIgnore: true in the global removal mode. It should be fixed in this release. Please test version 2.0.3 or newer and let me know if it works.

If you still encounter problems, feel free to report it here with a JSFiddle showing the problem and I'm happy to help/fix it.

ProblemsOfSumit
  • 19,543
  • 9
  • 50
  • 61