0

I've drawn a polygon and I want to draw a perpendicular line to this polygon. I found the computeOffset function of google maps api from here, but I'm using Leaflet. Is there an equivalent function in Leaflet?

Here is a screenshot of drawing the polyline.

enter image description here

I want to draw the perpendicular line that passes through the start point of the drawing polyline (the start point is marked with a marker on the screenshot). The expected result is like this.

enter image description here

Thank you.

Community
  • 1
  • 1
nermiiine
  • 167
  • 3
  • 14

1 Answers1

0

No, Leaflet has no equivalent.

You'll have to resort to a geodetic utility library for this kind of calculations. See cheap-ruler, geographiclib and Turf.js.

IvanSanchez
  • 18,272
  • 3
  • 30
  • 45
  • Thank you @IvanSanchez, I will make research for this libraries. I have a question, czn I use one of this libraries with Leaflet without any problem? – nermiiine Mar 01 '17 at 10:07
  • I can't find function for this issue in this libraries :( – nermiiine Mar 01 '17 at 11:07
  • Look harder. `computeOffset` is pretty much geographiclib's inverse geodesic problem resolver, and your original problem seems to be covered by TurfJS's `pointonline`. Define your problem better if you want a better pointer. – IvanSanchez Mar 01 '17 at 12:37
  • I don't think that **pointonline** will do the job, my issue is I have a polyline drawing on map and I want to draw another polyline which is perpendicular to the first polyline. Now I'm trying to do some mathematics, I hope that you can help me to find a useful function. Thank you – nermiiine Mar 01 '17 at 12:50
  • Define your problem better. Explain these things in your original question. Add examples, drawings, expected output for a given input. It's very hard to guess what you *exactly* are trying to do. – IvanSanchez Mar 01 '17 at 13:04
  • No, it's not clear. Show a set of inputs, and the expected result. And pay attention to the nomenclature of "polyline" and "line segment" – IvanSanchez Mar 01 '17 at 13:59
  • OK, clearer now. You need to solve the inverse geodetic problem (with geographiclib's `Inverse` or cheap-ruler's `bearing`), add 90 degrees to the bearing, then solve the direct geodetic problem (with geographiclib's `Direct` or cheap-ruler's `destination`) – IvanSanchez Mar 01 '17 at 15:07
  • Thank you @IvanSanchez for this indication, finaly I used bearing and I add to it 90 degrees as you said to get the perpendicular line, thank you for youe help :) – nermiiine Mar 01 '17 at 16:30