Remove icon position flicker on first load/player add

This commit is contained in:
Mike Primm 2011-06-03 09:51:41 -05:00
parent 38163133cb
commit 867c31573e

View File

@ -2,11 +2,12 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
var me = this; var me = this;
$(dynmap).bind('playeradded', function(event, player) { $(dynmap).bind('playeradded', function(event, player) {
// Create the player-marker. // Create the player-marker.
var markerPosition = null; var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
if(dynmap.world === player.location.world)
markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
player.marker = new CustomMarker(markerPosition, dynmap.map, function(div) { player.marker = new CustomMarker(markerPosition, dynmap.map, function(div) {
var playerImage; var playerImage;
player.marker.toggle(dynmap.world === player.location.world);
$(div) $(div)
.addClass('Marker') .addClass('Marker')
.addClass('playerMarker') .addClass('playerMarker')
@ -52,7 +53,6 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
} }
} }
}); });
}); });
$(dynmap).bind('playerremoved', function(event, player) { $(dynmap).bind('playerremoved', function(event, player) {
// Remove the marker. // Remove the marker.
@ -80,7 +80,7 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
for(name in dynmap.players) { for(name in dynmap.players) {
var player = dynmap.players[name]; var player = dynmap.players[name];
// Turn off marker - let update turn it back on // Turn off marker - let update turn it back on
player.marker.toggle(false); player.marker.hide();
} }
}); });
// Remove marker on map change - let update place it again // Remove marker on map change - let update place it again