Skip to content

Instantly share code, notes, and snippets.

@mathieue
Created April 17, 2014 08:17
Show Gist options
  • Save mathieue/10963840 to your computer and use it in GitHub Desktop.
Save mathieue/10963840 to your computer and use it in GitHub Desktop.
function updatearc() {
var point = [45.337, -0.472];
var point2 = [49.045, 2.153];
pathArcs.attr("d", function (d) {
var source = map.latLngToLayerPoint(new L.LatLng(point[0], point[1]));
var target = map.latLngToLayerPoint(new L.LatLng(point2[0], point2[1]));
var dx = target.x - source.x,
dy = target.y - source.y,
dr = Math.sqrt(dx * dx + dy * dy);
var arc = "M" + source.x + "," + source.y + "A" + dr + "," + dr + ",0 0 1 " + target.x + "," + target.y;
return arc;
})
.style({
stroke: '#0000ff',
'stroke-width': '20px'
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment