Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Editing GPX #56

Closed
citizenfish opened this issue Apr 17, 2017 · 1 comment
Closed

Question: Editing GPX #56

citizenfish opened this issue Apr 17, 2017 · 1 comment
Labels

Comments

@citizenfish
Copy link

Could the GPX be edited by a draw control for example https://github.com/Leaflet/Leaflet.draw.

I tried the following code but it did not appear to work. The GPX displays fine but the draw control cannot edit it?

var gpxLayer = new L.GPX(gpx, {async: true});
        gpxLayer.on('loaded', function(e) { map.fitBounds(e.target.getBounds());}); 
        map.addLayer(gpxLayer);

    var options = {
        position: 'topleft',
        draw : {
            polygon: false,
            circle: false,
            rectangle: false,
            marker: false,
            line: false
        },

        edit: {
            featureGroup: gpxLayer,
            remove: false
        }
    };

    var drawControl = new L.Control.Draw(options);
    map.addControl(drawControl);
@mpetazzoni
Copy link
Owner

I must say I've never tried this. If there is a way to make it work, keep in mind that all the metadata information calculated by leaflet-gpx is done when reading/parsing the original GPX file, so none of that information will be accurate once you start editing the features directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants