|
2017-12-20
, 13:24
|
Posts: 1,414 |
Thanked: 7,547 times |
Joined on Aug 2016
@ Estonia
|
#52
|
@rinigus is there a way to refresh the map after the style was changed?
|
2018-01-08
, 13:28
|
Posts: 58 |
Thanked: 223 times |
Joined on Apr 2017
@ Germany
|
#53
|
The Following User Says Thank You to jdrescher For This Useful Post: | ||
|
2018-01-08
, 13:42
|
Posts: 1,414 |
Thanked: 7,547 times |
Joined on Aug 2016
@ Estonia
|
#54
|
I have a problem in my app regarding the mapbox plugin.
After loading an autosave file, I would go through all recorded positions and then add each coordinate to an array. You can see the for statement in line 118.
Then in line 632, I would add each coordinate point to the map track.
And this line 632 is the problem. If the autosave is big enough e.g. >7000 coordinate points, the app will crash. Sometimes my phone even reboots then. Do you have an idea what could cause the problem?
The Following User Says Thank You to rinigus For This Useful Post: | ||
|
2018-01-08
, 14:12
|
Posts: 58 |
Thanked: 223 times |
Joined on Apr 2017
@ Germany
|
#55
|
Without digging too deep into the code - do you add each point as a separate layer or all points go as a vector into a single layer? So, whether you end up having 7000 layers or just few with many points?
//Start new trackline here //Create fresh temp line array vLineArray = []; //Write first coordinate of new track segment to line array vLineArray.push(coordinate); //Save that to global array vTrackLinePoints = vLineArray; sTrackLine = "lineTrack" + iPausePositionsIndex.toString(); //We have to create a track line here. map.addSourceLine(sTrackLine, vTrackLinePoints) map.addLayer("layerTrack" + iPausePositionsIndex.toString(), { "type": "line", "source": sTrackLine }) map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-join", "round"); map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-cap", "round"); map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-color", "red"); map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-width", 2.0);
updateSourceLine
//Create temp line array and set current points array to it. Must use a JS array here necause QML arrays don't allow for push! vLineArray = vTrackLinePoints; //Write first coordinate to line array vLineArray.push(coordinate); //Save that to global array vTrackLinePoints = vLineArray; map.updateSourceLine(sTrackLine, vTrackLinePoints);
The Following User Says Thank You to jdrescher For This Useful Post: | ||
|
2018-01-08
, 14:39
|
Posts: 1,414 |
Thanked: 7,547 times |
Joined on Aug 2016
@ Estonia
|
#56
|
I use a single layer. This is the place where the layer is created:Then every new coordinate is pushed to the array vTrackLinePoints. And then I useCode://Start new trackline here //Create fresh temp line array vLineArray = []; //Write first coordinate of new track segment to line array vLineArray.push(coordinate); //Save that to global array vTrackLinePoints = vLineArray; sTrackLine = "lineTrack" + iPausePositionsIndex.toString(); //We have to create a track line here. map.addSourceLine(sTrackLine, vTrackLinePoints) map.addLayer("layerTrack" + iPausePositionsIndex.toString(), { "type": "line", "source": sTrackLine }) map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-join", "round"); map.setLayoutProperty("layerTrack" + iPausePositionsIndex.toString(), "line-cap", "round"); map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-color", "red"); map.setPaintProperty("layerTrack" + iPausePositionsIndex.toString(), "line-width", 2.0);to redraw the track line:Code:updateSourceLineCode://Create temp line array and set current points array to it. Must use a JS array here necause QML arrays don't allow for push! vLineArray = vTrackLinePoints; //Write first coordinate to line array vLineArray.push(coordinate); //Save that to global array vTrackLinePoints = vLineArray; map.updateSourceLine(sTrackLine, vTrackLinePoints);
The Following User Says Thank You to rinigus For This Useful Post: | ||
|
2018-01-08
, 14:45
|
Posts: 1,414 |
Thanked: 7,547 times |
Joined on Aug 2016
@ Estonia
|
#57
|
The Following User Says Thank You to rinigus For This Useful Post: | ||
|
2018-01-08
, 18:06
|
Posts: 58 |
Thanked: 223 times |
Joined on Apr 2017
@ Germany
|
#58
|
And one more question: does it mean that you call updateSourceLine 7000 times (once per each point) during startup or is it all factored into one call?
|
2018-01-08
, 21:05
|
Posts: 1,414 |
Thanked: 7,547 times |
Joined on Aug 2016
@ Estonia
|
#59
|
That's correct, 7000 times during startup. And then somewhere in between it gets stuck and crashs.
While during workout it is called once every second. And it seems that this also leads to the crash after 2 hours or something.
You know, I think the amount of calls of the updatesourceline function is limited. Maybe it helps to split the track points to multiple layers of track lines. I will do some more tests tomorrow.
|
2018-01-09
, 06:47
|
Posts: 58 |
Thanked: 223 times |
Joined on Apr 2017
@ Germany
|
#60
|