-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating a track continuously (live tracking) #273
Comments
Hi @jarod46,
👋 Raruto |
Ha, it's a generaly question, I'm not sure what I need to share, basically I have a timer which regularly call an ajax function which query if there is new locations to add to the current track. I tried with several functions like function updateLocations(data) {
if (data && Array.isArray(data) && data.length > 0) {
var newFeature = {
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": []
},
"properties": {
"name": "KTrackPlus",
"description": "",
"coordTimes": [],
}
};
for (var i = 0; i < data.length; i++) {
if (i > 1000) break;
var newCoords = [Number(data[i].lng), Number(data[i].lat), Number(data[i].alt), Number(data[i].timestamp)];
newFeature.geometry.coordinates.push(newCoords);
var date = new Date(Number(data[i].timestamp) * 1000);
newFeature.properties.coordTimes.push(date.toISOString());
mostRecentTT = data[i].timestamp;
locs.push(newCoords);
}
controlElevation._loadLayer(newFeature);
/*if (firstTime) {
//var jsonStr = JSON.stringify(newFeature);
//controlElevation.load(jsonStr);
trackLayer = controlElevation._loadLayer(newFeature);
}
else {
controlElevation.addData(newFeature, trackLayer);
controlElevation._initMapIntegrations(trackLayer);
}*/
controlElevation.redraw();
}
} Full page (witthout php part) https://pastebin.com/DemqTPUj |
I think you are already on the right path: You probably just need to dive a little deeper into the code's flow and choose the one that's right for you: leaflet-elevation/src/control.js Lines 340 to 369 in ea15556
leaflet-elevation/src/control.js Lines 371 to 387 in ea15556
NB: As you go further and further down, you will have to handle everything else by yourself, eg: leaflet-elevation/src/control.js Lines 29 to 44 in ea15556
👋 Raruto |
Hello, I searching for a solution from hours, so I finally decided to ask for help.
I try to found a way to load and update a track continuously, for a live tracking purpose, that work almost perfect, but I don't like the behavior which create a track segment at each time I add new points. I was able to hide this on the chart by css overriding, but that sill to show correctly the distance markers.
Expected behaviour
A way to add new datas to the actual track and update the entire track on the map
Actual behaviour
Adding new datas create a new track segment, resulting of unwanted distance markers display
So, there is actually a way to do that, or it's just not possible yet ?
Thanks.
The text was updated successfully, but these errors were encountered: