Working on a game where you can fly from one city to another. Cities are represented by circles and do have a unique ID. Every trip is recorded in a table.
Now what I want to do is draw a line between two cities to show the travel history.
Is there a function to say (in JS) "draw a line from startX/startY to endX/endY" ?
Again: Thanks. I've already had a look at your "canvas-fun". There you use "lines" to create the canvas - but I can't even figure out where that element is ...
One could also just set the innerHTML to a SVG markup to avoid SVG.js. This is pretty small and brute force, and doesn't even care to manipulate an existing SVG (potential optimization here).
Sorry to molest you again - I added svg.min.js to the header and put a rectangle with class .SVG-container underneath everything - but I get the error "SVG is not defined". Can't add the HYPE here because it heavily depends on Ajax and data from a DB.
Added the functionality (copied from your code) like so:
var parameter={
maid : maid
};
jQuery.ajax({
url : pfad+"weltreise_tourdaten_laden.php",
data: parameter
})
.done(function(response){
var dummy=response.split("|");
if (dummy[0]=="OK") {
// IDs der Städte kommen zurück
var start=dummy[1].split(",");
var ziel=dummy[2].split(",");
var svgElm = element.querySelector('.SVG-container');
var draw = SVG().addTo(svgElm).size(1240, 800);
for (i=0; i<ziel.length; i++) {
var start_coordinates=$("#"+start[i]).offset();
var ziel_coordinates=$("#"+ziel[i]).offset();
var line = draw.line(start_coordinates.left, start_coordinates.top, ziel_coordinates.left, ziel_coordinates.top).move(20, 20);
line.stroke({ color: '#f06', width: 5, linecap: 'round' });
}
}else{
alert(response);
}
})
.fail(function(xhr, status, errorThrown) {
alert("Ajax Fehler.\nStatus="+status+"\nFehler="+errorThrown,"error");
});