I want to create a map like this.
My code is done and works BUT the server limits me to 40 requests/minute, so I need to slow my requests down. I found out that I reach the server limit with even one City in my .csv list (it should just send one request).
The Errors show me that my loop doesn't stop sending requests with the same city to the server, until the server limit is reached.
I want the loop to execute each .length
once and just once.
Whats wrong?
var Städte;
var data;
var profile = 'driving-car'
var preference = 'fastest'
function setup() {
createCanvas(2000,2000);
loadJSON('URL', gotData);
Städte = loadStrings ('v3.1.csv');
}
function gotData(data) {
var route = data.features;
for (var j = 0; j <= 1; j++ ) {
var citydata = Städte[j].split(/,/);
var lon = citydata[3];
var lat = citydata[2];
loadJSON('URL', gotData);
beginShape();
for (var i = 0; i < route[0].geometry.coordinates.length; i=i+500) {
var x = route[0].geometry.coordinates[i][0];
var y = route[0].geometry.coordinates[i][1];
noFill();
vertex(x*100-200,-y*100+6000);
}
endShape();
}
}