Put markers in a component, add generic component update messages
This commit is contained in:
parent
e4f0a17161
commit
0338bb6f3a
7 changed files with 151 additions and 46 deletions
|
|
@ -499,6 +499,9 @@ DynMap.prototype = {
|
|||
},
|
||||
playerquit: function() {
|
||||
$(me).trigger('playerquit', [ update.playerName ]);
|
||||
},
|
||||
component: function() {
|
||||
$(me).trigger('component.' + update.ctype, [ update ]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
34
web/js/markers.js
Normal file
34
web/js/markers.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
var dynmapmarkersets = {};
|
||||
|
||||
componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
function loadmarkers(world) {
|
||||
dynmapmarkersets = {};
|
||||
$.getJSON(dynmap.options.tileUrl+'_markers_/marker_'+world+'.json', function(data) {
|
||||
var ts = data.timestamp;
|
||||
$.each(data.sets, function(name, markerset) {
|
||||
dynmapmarkersets[name] = markerset;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(dynmap).bind('component.markers', function(event, msg) {
|
||||
console.log('got marker event - ' + msg.ctype + ', ' + msg.msg);
|
||||
});
|
||||
|
||||
// Remove marker on start of map change
|
||||
$(dynmap).bind('mapchanging', function(event) {
|
||||
});
|
||||
// Remove marker on map change - let update place it again
|
||||
$(dynmap).bind('mapchanged', function(event) {
|
||||
});
|
||||
// Load markers for new world
|
||||
$(dynmap).bind('worldchanged', function(event) {
|
||||
loadmarkers(this.world.name);
|
||||
});
|
||||
|
||||
loadmarkers(dynmap.world.name);
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue