Giter VIP home page Giter VIP logo

Comments (3)

Falke-Design avatar Falke-Design commented on June 5, 2024

Geoman doesn't support this but maybe with this information you get the right way:

All the markers are stored in the layerGroup and markers, so you can remove all layers from this lists and then recreate all the markers again with _createMarker

_createMarker(latlng) {
// create the new marker
const marker = new L.Marker(latlng, {
draggable: false,
icon: L.divIcon({ className: 'marker-icon' }),
});
this._setPane(marker, 'vertexPane');
marker._pmTempLayer = true;
// add it to the map
this._layerGroup.addLayer(marker);
this._markers.push(marker);

Also checkout the generation / redrawing of the markers in edit mode:

from leaflet-geoman.

brunstruts avatar brunstruts commented on June 5, 2024

Thank you for the reply
I tried to clear all layers and set new markers (a lot like how it was done in _initMarkers()):

                map.pm.Draw.Line._layerGroup.clearLayers();
                map.pm.Draw.Line._layerGroup = new LayerGroup();
                map.pm.Draw.Line._layerGroup._pmTempLayer = true;

                map.pm.Draw.Line._markers = newCoords.map((latlng) => {
                    return map.pm.Draw.Line._createMarker(latlng);
                });

                map.addLayer(map.pm.Draw.Line._layerGroup);

And the marker was removed! But sadly the path got removed along with it. Updating the path with updatePath() did nothing either. Any more ideas?

from leaflet-geoman.

brunstruts avatar brunstruts commented on June 5, 2024

I made it work!

while (map.pm.Draw.Line._markers.length > 1) {
          map.pm.Draw.Line._removeLastVertex();
}
newCoords.forEach((latlng) => {
    map.pm.Draw.Line._createVertex({latlng: latlng});
});

This works as long as I don't need the first vertex changed, which so far is not a condition.
Thanks for all the help!

from leaflet-geoman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.