-
Notifications
You must be signed in to change notification settings - Fork 135
Description
I have a map with Black Sea currents https://syroco.rmri.ro/earth/index.html
When I click on Black Sea Currents layer, the map it's ok, but when I click on play button (from time controller) the map it's empty.
I have a function for split data into 24 parts (one per hour), so when I click on play button, the map need to change content (loop through all 24 parts).
`
function splitDataInto24Parts(data) {
const numParts = 24;
const partSize = Math.floor(data.length / numParts);
const splitData = [];
for (let i = 0; i < numParts; i++) {
const start = i * partSize;
const end = (i + 1) * partSize;
splitData.push(data.slice(start, end));
}
return splitData;
}`
My currents data it's in json format:
[
{"header": {"parameterUnit":"m/","parameterNumber":2,"dx":0.02500000000000001,"dy":0.025000000000000015,"time":"2024-12-17T00:00:00.000Z","parameterCategory":2,"nx":578,"ny":258,"la1":47.325,"lo1":27.4,"sign":1}, "data": [0.0,....]
,
{"header": {"parameterUnit":"m/","parameterNumber":3,"dx":0.02500000000000001,"dy":0.025000000000000015,"time":"2024-12-17T00:00:00.000Z","parameterCategory":2,"nx":578,"ny":258,"la1":47.325,"lo1":27.4,"sign":1}, "data": [0.0,....]
]
Code for load json file:
`
$.getJSON(fileName, function(data) {
const splitData = splitDataInto24Parts(data);
var velocityLayer = L.velocityLayer({
displayValues: true,
displayOptions: {
velocityType: "Currents",
position: "bottomleft",
emptyString: "No water data"
},
velocityOptions: {
particleMultiplier: 1
},
data: data,
minVelocity: -0.44,
maxVelocity: 0.26,
velocityScale: 0.3
});
layerControl.addOverlay(velocityLayer, "Black Sea Currents");
// Update the data when the time changes
map.timeDimension.on("timeload", function(event) {
const currentTimeIndex = map.timeDimension.getCurrentTimeIndex();
velocityLayer.setData(splitData[currentTimeIndex]);
});
});`
I am looking forward to any advice or ideas.