Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda