Comments (6)
yes, I can add an option for that
from l.control.linestringselect.
@jb2b38, how do you want to define the first(fixed) point?
from l.control.linestringselect.
I already know the coordinates of a point of interest that will be on the polyline, so passing those coordinates would be great :)
from l.control.linestringselect.
@w8r I was able to add a snapping functionality by changing the closestPointOnSegment a bit. It looks like this:
function closestPointOnSegment(p2, p0, p1) {
var snap_distance = 30;
var point0 = new L.latLng(p0[0], p0[1]);
var point1 = new L.latLng(p1[0], p1[1]);
var point2 = new L.latLng(p2[0], p2[1]);
var distance;
if (point2.distanceTo(point0) < point2.distanceTo(point1)) {
distance = point2.distanceTo(point0);
if (distance < snap_distance) {
return p0;
}
} else {
distance = point2.distanceTo(point1);
if (distance < snap_distance) {
return p1;
}
}
var t = pointLineSegmentParameter(p2, p0, p1),
x10 = p1[0] - p0[0],
y10 = p1[1] - p0[1],
p3 = [p0[0] + t * x10, p0[1] + t * y10];
return p3;
}
from l.control.linestringselect.
@jb2b38,
Do you want me to include that as an option? something like
new LineStringSelect({ snapping: distance});
from l.control.linestringselect.
@w8r I think it'd be more useful for other uses if you can make it an option. I only did this quickly to have it work the way I need it at the moment, but it'd be more flexible :) How can I help you to only have a selection forward? I'm trying to figure how works the code but I don't really know where to look for this behaviour.
from l.control.linestringselect.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from l.control.linestringselect.