GithubHelp home page GithubHelp logo

Comments (6)

w8r avatar w8r commented on May 28, 2024

yes, I can add an option for that

from l.control.linestringselect.

w8r avatar w8r commented on May 28, 2024

@jb2b38, how do you want to define the first(fixed) point?

from l.control.linestringselect.

jb2b38 avatar jb2b38 commented on May 28, 2024

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.

jb2b38 avatar jb2b38 commented on May 28, 2024

@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.

w8r avatar w8r commented on May 28, 2024

@jb2b38, 👍 👍

Do you want me to include that as an option? something like

new LineStringSelect({ snapping: distance});

from l.control.linestringselect.

jb2b38 avatar jb2b38 commented on May 28, 2024

@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 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.