mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Add 'hidey' option to 'coord' component - option to show just X,Z
This commit is contained in:
parent
893117d638
commit
82318346c2
@ -101,6 +101,7 @@ components:
|
||||
- class: org.dynmap.ClientComponent
|
||||
type: coord
|
||||
label: "Location"
|
||||
hidey: false
|
||||
|
||||
#- class: org.dynmap.ClientComponent
|
||||
# type: logo
|
||||
|
@ -877,6 +877,10 @@
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.dynmap .coord-control-noy {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.dynmap .coord-control .coord-control-label {
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ componentconstructors['coord'] = function(dynmap, configuration) {
|
||||
valfield: $('<span/>'),
|
||||
|
||||
onAdd: function(map) {
|
||||
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);
|
||||
@ -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);
|
||||
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;
|
||||
if(configuration.hidey)
|
||||
coord.valfield.text('---,---');
|
||||
else
|
||||
coord.valfield.text('---,---,---');
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user