Add 'hidey' option to 'coord' component - option to show just X,Z

This commit is contained in:
Mike Primm 2011-12-03 04:31:05 +08:00 committed by mikeprimm
parent 893117d638
commit 82318346c2
3 changed files with 17 additions and 3 deletions

View File

@ -101,6 +101,7 @@ components:
- class: org.dynmap.ClientComponent
type: coord
label: "Location"
hidey: false
#- class: org.dynmap.ClientComponent
# type: logo

View File

@ -877,6 +877,10 @@
border-radius: 5px;
}
.dynmap .coord-control-noy {
width: 60px;
}
.dynmap .coord-control .coord-control-label {
}

View File

@ -4,7 +4,10 @@ componentconstructors['coord'] = function(dynmap, configuration) {
valfield: $('<span/>'),
onAdd: function(map) {
this._container = L.DomUtil.create('div', 'coord-control');
if(configuration.hidey)
this._container = L.DomUtil.create('div', 'coord-control coord-control-noy');
else
this._container = L.DomUtil.create('div', 'coord-control');
this._map = map;
$('<span/>').addClass('coord-control-label').text((configuration.label || 'x,y,z') + ': ').appendTo(this._container);
$('<br/>').appendTo(this._container);
@ -31,10 +34,16 @@ componentconstructors['coord'] = function(dynmap, configuration) {
dynmap.map.on('mousemove', function(mevent) {
if(!dynmap.map) return;
var loc = dynmap.getProjection().fromLatLngToLocation(mevent.latlng, 64);
coord.valfield.text(Math.round(loc.x) + ',' + loc.y + ',' + Math.round(loc.z));
if(configuration.hidey)
coord.valfield.text(Math.round(loc.x) + ',' + Math.round(loc.z));
else
coord.valfield.text(Math.round(loc.x) + ',' + loc.y + ',' + Math.round(loc.z));
});
dynmap.map.on('mouseout', function(mevent) {
if(!dynmap.map) return;
coord.valfield.text('---,---,---');
if(configuration.hidey)
coord.valfield.text('---,---');
else
coord.valfield.text('---,---,---');
});
};