Giter VIP home page Giter VIP logo

leaflet-freehandshapes's People

Contributors

avscta avatar bozdoz avatar cynthiameng avatar dependabot[bot] avatar ivan-perez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

leaflet-freehandshapes's Issues

Forced polygons

Hi there, there is a way to forced LatLng to a polygon? I want to create a polygon passing the coordinates into it.

something like:

freehandshapes.create([
[0,0],[0,1],[1,0],[1,1],[0,0]
]);

Finished drawing

Hi guys, is there a way to know when the user finishes the drawing? An event, perhaps?

I found:

  stopDraw : function () {
        this.creating = false;
        this.resetTracer();
        this.drawStartedEvents('off');
        this.setMapPermissions('enable');
    }

I tried to display a simple console.log to test the event in index.js, but nothing happened

The drawing operation Endding automatically

Thanks for this great plugin!
I have an issue with Chrome on mobile.
The drawing operation Endding automatically sometimes.

image

var drawLayers = new L.LayerGroup()
drawer = new L.FreeHandShapes({
	polygon: {
		color: '#2e6da4',
		fillColor: '#337ab7',
		weight: 3,
		smoothFactor: 1
	},
	polyline: {
		color: '#337ab7',
		smoothFactor: 0
	}
});

drawer.setMode('add');
drawLayers.addLayer(drawer);
drawLayers.addTo(map);

Thanks for your help!

Bug: onRemove should turn-off all events but actually 'mouseleave' not turned-off

I use
leaflet-freehandshapes version: 0.3.7
leaflet version: 1.6.0

I'm also have fix for that bug:
replace this line: L.DomEvent[onoff](document.body, "mouseleave", this.mouseUpLeave.bind(this))

to this: L.DomEvent[onoff](document.body, "mouseleave", this.mouseUpLeave, this);

when I pull with npm:
npm i leaflet-freehandshapes - I get this bug.
If I pull it from github- It's already fixed.
It's the same version in package.json: 0.3.7- how it can be posssible?

Touch support for Chrome

How did you make this work on Chrome? I understand this plugin has been forked from FreeDraw, which doesn't work on Chrome.

Thanks in advance.

Not free-hand

Hello my friend, I've been using freeDraw for a few months but it has some limitations that this plugin solves, I'm very interested in integrating it into my app.

  • However, I am not able to create the polygons right. The free hand is not working for me, it must be something simple but I am not finding the problem. I did the following:

            require('leaflet-freehandshapes');
            var drawer = new L.FreeHandShapes({
                polygon: {
                    color: '#2e6da4',
                    fillColor: '#337ab7',
                    weight: 3,
                    smoothFactor: 1
                },
                polyline: {
                    color: '#337ab7',
                    smoothFactor: 0
                }
            });

            console.log(drawer)
  
            //change draw mode
            document.getElementById('mode').onchange = function() {
                switch (this.value) {
                    case 'nothing':
                        drawer.setMode('view');
                        break;
                    case 'draw':
                        drawer.addTo(mymap)
                        drawer.setMode('add');
                        break;
                    default:
                        break;
                }
            }

The result is this:
1
Image 1
2
Image 2

As you can see, I'm trying to create a polygon with this shape, and the result is completely different.
I hope you can help me, thank you !!

'Add layer' event fires prematurely on Android

Hi. First of all, thank you very much for this great library!

Take this example: http://app.cesens.com/f.php Touch the "Add" button in order to set the plugin to add mode. The first time you draw a line, the touchend event is fired too early (before you actually release your finger out the screen), and thus the 'layeradd' event of this plugin, provinding an incomplete polygon. But the next times you draw a line to make a polygon, it works as expected.

Here is a video showing the effect, just in case you can't replicate the behaviour: https://app.cesens.com/free-hand-shapes-demo.mp4 You can see that I try twice to draw the circle, as the first time always gets cancelled prematurely.

This always happens to me on Chrome for Android. The problem doesn't happen neither on iOS nor on desktop with a mouse.

Thanks!

Problem draw in mobile at first time in React

Hello everybody,

First of all thank you for develop and iterate this amazing library

Using it, I found a problem on mobile mode in my react project (see atteched video). I found a solution by removing these lines of code in src / index.js

if (mode === 'add' || mode === 'subtract') {
this._map.dragging.disable();
} else {
this._map.dragging.enable();
}

I think that is not necessary disabled map dragging when you start to draw. Please, could you analize this change? If you need a demo I can make one with "react" and "react-leaflet" using this library.

Thank you very much!

deepin-screen-recorder_Select area_20211115134049

Event handlers are not cleaned up correctly when map is removed

Hi everyone,

I would like to present 2 scenarios in which the plugin fails to cleaned up event handlers when the leaflet map is reinitialised

Scenario 1

In this scenario, only importing the plugin without actually making any use of it will trigger the problem. When the map is first loaded you can click, zoom or pan without any trouble. However, when you reinitialise using the button, every interaction with the map will now trigger an error.

The bug happens due to these lines, which fail to pass the context in which the handlers should be de-registered (as well as 1 line calling "on" instead of "off"):

removeHooks: function() {
L.DomEvent.off(this._container, "touchstart", this._onTouchStart);
L.DomEvent.on(this._container, "touchmove", this._onTouchMove, this);
L.DomEvent.off(this._container, "touchend", this._onTouchEnd);

Scenario 2

When the map is first loaded, it works fine, but when the map is reinitialised, you then get an error everytime you move the mouse out. This is the same issue referenced in #23

The issue happens due to this line and needs the fix mentioned in #23 :

L.DomEvent[onoff](document.body, "mouseleave", this.mouseUpLeave.bind(this));

I will add relevant examples shortly.

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.