Commit 620c06e2 authored by Corentin Mors's avatar Corentin Mors
Browse files

Fix handling features in client side

parent c3c31dcc
......@@ -368,7 +368,7 @@ $(function() {
}));
// Get rid of legacy login system
const urlParams = new URLSearchParams(window.location.search);
username = urlParams.get('u');
socket.emit('add user', username);
......@@ -380,7 +380,7 @@ $(function() {
geolocation.on('change:position', function() {
map.getView().setCenter(geolocation.getPosition());
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ?
new Point(coordinates) : null);
......@@ -393,34 +393,39 @@ $(function() {
features: [accuracyFeature, positionFeature]
})
});
//mylayer.getSource().addFeature(positionFeature2);
function moveParticipantPoint(data){
console.log("Got data " + data.coordinates + " from " + data.username);
userPositions[data.username] = new Feature();
userPositions[data.username].setStyle(new Style({
image: new CircleStyle({
radius: 6,
fill: new Fill({
color: '#ec0a0a'
}),
stroke: new Stroke({
color: '#fff',
width: 2
if (userPositions[data.username] != null) {
// The point exist we pass
}
else{
userPositions[data.username] = new Feature();
userPositions[data.username].setStyle(new Style({
image: new CircleStyle({
radius: 6,
fill: new Fill({
color: '#ec0a0a'
}),
stroke: new Stroke({
color: '#fff',
width: 2
})
})
})
}));
}));
mylayer.getSource().addFeature(userPositions[data.username]);
}
userPositions[data.username].setGeometry(data.coordinates ?
new Point(data.coordinates) : null);
mylayer.getSource().addFeature(userPositions[data.username]);
//console.log(mylayer.getSource().getFeatures());
}
function removeParticipantPoint(data){
console.log("Got del session from " + data.username);
userPositions[data.username].setGeometry(null);
mylayer.getSource().removeFeature(userPositions[data.username]);
delete userPositions[data.username];
mylayer.getSource().refresh();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment