Commit e3d5c024 authored by Corentin Mors's avatar Corentin Mors
Browse files

Add name and center onclick on user location

parent b36cc17a
......@@ -69,7 +69,7 @@ $(function() {
$typingMessages.remove();
}
var $usernameDiv = $('<span class="username"/>')
var $usernameDiv = $('<span udata="'+data.username+'" class="username"/>')
.text(data.username)
.css('color', getUsernameColor(data.username));
var $messageBodyDiv = $('<span class="messageBody">');
......@@ -343,7 +343,19 @@ $(function() {
var positionFeature = new Feature();
positionFeature.setStyle(new Style({
image: new CircleStyle({
radius: 6,
radius: 7,
fill: new Fill({
color: getUsernameColor(username)
}),
stroke: new Stroke({
color: '#fff',
width: 2
})
}),
text: new Text({
font: '16px sans-serif',
text: username,
offsetY: -16,
fill: new Fill({
color: getUsernameColor(username)
}),
......@@ -392,6 +404,18 @@ $(function() {
color: '#fff',
width: 2
})
}),
text: new Text({
font: '16px sans-serif',
text: data.username,
offsetY: -16,
fill: new Fill({
color: getUsernameColor(data.username)
}),
stroke: new Stroke({
color: '#fff',
width: 2
})
})
}));
mylayer.getSource().addFeature(userPositions[data.username]);
......@@ -412,6 +436,15 @@ $(function() {
mylayer.getSource().refresh();
}
$( ".messages" ).on( "click", ".username", function() {
if(userPositions[this.getAttribute('udata')] == undefined){
map.getView().setCenter(geolocation.getPosition());
}
else{
map.getView().setCenter(userPositions[this.getAttribute('udata')].getGeometry().getCoordinates());
}
});
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
......
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