I am trying to use Leaflet.Geodesic.js geodesic to draw a geodesic line between two points, but I don't see any line at all.

Based on the Leaflet.Geodesic.js example script, this is what I have tried...

var Geodesic = L.geodesic([[52.5, 13.35, 33.82, -118.38]], {
opacity: 1,
color: 'red',
steps: 50
}).addTo(map);

Can anyone help me see what I'm doing wrong?

  • Have you tried the exact same example from the docs that you built upon? – bugmenot123 Nov 13 at 9:03
  • Yes I have but for some reason it doesn't work for me, I can add Polylines but not Geodesic lines. – Taffman Nov 13 at 11:08
  • I have now solved this by directly linking to the Leaflet.Geodesic.js script on the authors demo site. Any attempt to use a locally stored copy fails. Must be finger trouble my end but for the life of me I cant see any error. Anyway this issue is now closed. – Taffman Nov 13 at 11:43
  • @Taffman, have you seen an answer offered by me? – Taras Nov 13 at 11:53
var Geodesic = L.geodesic([[[52.5, 13.35], [33.82, -118.38]]], {
  opacity: 1,
  color: 'red',
  steps: 50
}).addTo(map);

Instantiates a polyline object given an array [point_1, point_2, point_3] of geographical points, which is basically an array of arrays of LatLng points [[lat1, lng1], [lat2, lng2], [lat3, lng3]].

References:

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.