Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

388
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda