bozdoz / leaflet-freehandshapes Goto Github PK
View Code? Open in Web Editor NEWRefactored Leaflet shape drawing plugin. Forked with <3 from Leaflet.FreeDraw
Home Page: https://bozdoz.github.io/leaflet-freehandshapes/
License: Other
Refactored Leaflet shape drawing plugin. Forked with <3 from Leaflet.FreeDraw
Home Page: https://bozdoz.github.io/leaflet-freehandshapes/
License: Other
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]
]);
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
Hey, how can I get drawn polygon coordinates and how can I clear the map from polygons If I need to ?
Thanks for this great plugin!
I have an issue with Chrome on mobile.
The drawing operation Endding automatically sometimes.
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!
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?
Is there a method I can use to simply draw the polyline and then don't fill the polygon afterwards? I just want a line.
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.
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.
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:
Image 1
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 !!
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!
Hello everyone, thanks for the development of the library, but we have detected an incompatibility problem with the recent version of leaflet 1.7.1
Is there a solution to the problem?
Thank you
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
leaflet-freehandshapes/src/index.js
Lines 476 to 480 in dc7d983
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!
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
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"):
leaflet-freehandshapes/dist/leaflet-freehandshapes.js
Lines 17486 to 17489 in dc7d983
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 :
leaflet-freehandshapes/dist/leaflet-freehandshapes.js
Line 17225 in dc7d983
I will add relevant examples shortly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.