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

Drawing over start of line deletes part of the line #2

Open
Jakst3r opened this issue Jun 15, 2018 · 7 comments
Open

Drawing over start of line deletes part of the line #2

Jakst3r opened this issue Jun 15, 2018 · 7 comments

Comments

@Jakst3r
Copy link

Jakst3r commented Jun 15, 2018

This is an awesome plugin but there is one issue thats preventing me from using it.

When drawing it seems if you draw over that start of the line it deletes part of the line, I have linked a screen recording to help explain.

Video: https://youtu.be/AiDOzJPEdRs

Unrelated but after drawing for about 20 seconds chrome bug out and the page has to be reloaded.

Regards
Jack

@tcoupin
Copy link
Owner

tcoupin commented Jun 17, 2018

Thanks for trying using it !

I've tried some optimization (stack event to process one by one, cache some values in variables) but bug seems to be style there.

I think this issue is related to Turfjs/turf#1393 when 2 events are fired on the same latlng

@tcoupin
Copy link
Owner

tcoupin commented Jun 17, 2018

Difference is for erasing...

The turfjs lib has issue for union too: Turfjs/turf#1209 (comment)

@tcoupin
Copy link
Owner

tcoupin commented Jun 17, 2018

I reproduce the bug : https://www.youtube.com/watch?v=4orbvl_xyg0&feature=youtu.be

The 2 functions uses 'martinez-polygon-clipping' : https://github.com/w8r/martinez

@gianluigiruggeri
Copy link

gianluigiruggeri commented Jul 17, 2018

Hi @tcoupin
thanks for your plugin. Are some updates for these issues?
In particular, trying to use you demo page I see a lot of times the Chrome page crashes

@lukszi
Copy link

lukszi commented Mar 7, 2019

I'm guessing that @tcoupin wants to wait for the official v7 release of turfjs, which is built with a martinez version that fixes these bugs.

If you really need these bugs gone and don't care about potential other bugs, you can easily build this yourself with the v7-alpha by replacing the _draw function in PaintPolygon,js with:

_draw: function (latlng, zoom, radius) {
        if (this._data === undefined || this._data === null) {
            this.setData(this._getCircleAsPolygon(latlng, zoom, radius));
        } else {
            let fc = {
                type: "FeatureCollection",
                features:[this._data, this._getCircleAsPolygon(latlng, zoom, radius)]
            };
            this.setData(turf.union(fc));
        }
    }

replacing the myTurf.js with:

import circle from 'turf/src/circle';
import union from 'turf/src/union/';
import difference from 'turf/src/difference';


let turf = {
	circle: circle,
	union: union,
	difference: difference
};

export default turf;

and adding

"turf": "7.0.0-alpha.1"

to your package.json

tcoupin added a commit that referenced this issue Apr 13, 2019
@tcoupin
Copy link
Owner

tcoupin commented Apr 13, 2019

Sorry for delay, I am not an expert of Turf (@lukszi seems to be one ;) ) and I don't work no more with leaflet and geodata (only on my free time).

I just publish 1.2.1-alpha.1 based on turf 7.0.0-alpha.1 following @lukszi instructions.

@papajds
Copy link

papajds commented Mar 6, 2022

Hello,
Do you have a solution to display the coordinates of the final polygon in a text area (textarea) or other
Or as a message like "alert...."
thanks

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

No branches or pull requests

5 participants