Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

380
Views
Leaflet Draw - Editing Polygon: Editing does not behave right

i am currently working on a project where a user should be able to edit zones (= polygons). I have created a class Zone which extends L.Polygon so I can create zones and add them to the map. The editing of a specific instance of Zone is triggered by a button, which rund the following code: specificZone.editable.enable() This works so far and looks like this:

editing points of zone/polygon

The problem I have, is that when dragging the edit points around, one corner point always behaves like an edge point: So it splits the corner like this:

enter image description here

The other points behave as intended. I hope this was somewhat understandable outlined. I am thankful for any kind of help. Have a nice day :)

Kind regards Luca

Edit:

My map gets created as follows:

A Vue Component Map.vue creates an instance of CustomMap.ts:

    const customMap = new CustomMap(
      document.getElementById("mapcontainer") as HTMLElement,
      mapUrl,
      mapParams.getData()
    );

the mapUrl is the place where the map is stored and the mapParams are previously loaded from a server

In the constructor of CustomMap.ts a L.DrawMap gets created, then the map gets added to the map as an instance of CustomImageOverlay which creates a L.imageOverlay. After that the L.FeatureGroup for the CustomZone(s) gets created.

        this.map = L.map(el, {
            crs: L.CRS.Simple,
            center: [0, 0],
            zoom: 4,
            minZoom: 2,
            maxZoom: 7,
            dragging: true,
            maxBoundsViscosity: 0.5,
            maxBounds: mapBounds,
            zoomSnap: 0.25,
            zoomDelta: 0.25,
            attributionControl: false
        });

        this.imageOverlay = new CustomImageOverlay(
          mapUrl,
          mapBounds.getNorthEast(),
          mapBounds.getSouthWest(),
          {
            opacity: 0.5,
            interactive: true,
            zIndex: -1
          },
          this.map
        );

        this.map.addLayer(this.imageOverlay.getLayer());

        // Create a group for zones and add it to map
        const zoneGroup = new L.FeatureGroup();
        zoneGroup.addTo(this.map);
       
        // init drawers
        this.polygonDrawer = new L.Draw.Polygon(this.map);

        // Layers to show/hide
        const overlayLayers: L.Control.LayersObject = {
            Zones: zoneGroup,
        };
        // Create Layer Control with the previous options
        const layerControl = new L.Control.Layers(base, overlayLayers);
        // Add to map
        layerControl.addTo(this.map);

The CustomZone is created and added to the feature group and map.

In the constructor of the customZone the actual polygon gets created by super(latlng, options)

I hope this code gives you better insight :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!