springmeyer/arc.js

The arc is a straight line

Closed this issue · 3 comments

Hi, I'm using this code to do a small test, and it just displays a straight line. I notice that if I use coordinates far from each other(cross Atlantic), there is a VERY slight curve, but only just.
Is there anything that I'm doing wrong? If you can put these coordinates working, could you provide the most basic example on how you did it?
Thanks

//load_map.js
window.onload = onLoad

function onLoad(){
var map = L.map('map').setView([32.75,-16.97], 11)

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);

var arc = L.Polyline.Arc([32.6936836, -16.7753468], [32.75, -16.97],
{
color: "red",
vertices: 200,
offset:10
}).addTo(map)
}

//index.html


     <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
     <!-- <script src="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.js"></script>   I tested with both files-->

     <script src='http://api.mapbox.com/mapbox.js/plugins/arc.js/v0.1.0/arc.js'></script>
     <script src='Leaflet.Arc.js'></script>
     <script src="load_map.js"></script>
</head>
<body>
    <div id="map"></div>
</body>

mapa

tmcw commented

These coordinates are very close to each other, and in the screenshot that's clear; this is definitely not crossing the atlantic. The generated arc looks correct.

Shouldn't the effect be the same regardless of the distance? I see some trignometric is used with a step for the number of points requested. Shouldn't it behave the same because of that?

I meant to say: i ALSO "notice that if I use coordinates far from each other(cross Atlantic), there is a VERY slight curve, but only just."

Blue line: straight
Red line: arc (but only just)
It is a reaaaaaly slight arc. Is it really supose to be like this? I've seen from other printscreens much more parabolical lines.
I'm using [32.6936836, -16.7753468], [0, 0]
image

Would there be a way to define the angle/radius ?

tmcw commented

This library generates great circle arcs, which are a geographically-defined arc. If you're looking for arbitrary curves for graphical purposes, you'll want to use something else.