Thread: [SailfishOS] Mapbox GL Native QML plugin
View Single Post
Posts: 58 | Thanked: 223 times | Joined on Apr 2017 @ Germany
#55
Originally Posted by rinigus View Post
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?
I use a single layer. This is the place where the layer is created:
Code:
//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);
Then every new coordinate is pushed to the array vTrackLinePoints. And then I use
Code:
updateSourceLine
to redraw the track line:
Code:
//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: