mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Add hidebydefault option for regions layers
This commit is contained in:
parent
106e470898
commit
c353d9aae6
@ -91,6 +91,8 @@ components:
|
|||||||
# customstyle:
|
# customstyle:
|
||||||
# homebase:
|
# homebase:
|
||||||
# strokeColor: "#00FF00"
|
# strokeColor: "#00FF00"
|
||||||
|
# # Optional - make layer hidden by default
|
||||||
|
# hidebydefault: true
|
||||||
|
|
||||||
#- class: org.dynmap.regions.RegionsComponent
|
#- class: org.dynmap.regions.RegionsComponent
|
||||||
# type: regions
|
# type: regions
|
||||||
@ -122,6 +124,8 @@ components:
|
|||||||
# groupstyle:
|
# groupstyle:
|
||||||
# homebase:
|
# homebase:
|
||||||
# strokeColor: "#007F00"
|
# strokeColor: "#007F00"
|
||||||
|
# # Optional - make layer hidden by default
|
||||||
|
# hidebydefault: true
|
||||||
|
|
||||||
#- class: org.dynmap.regions.RegionsComponent
|
#- class: org.dynmap.regions.RegionsComponent
|
||||||
# type: regions
|
# type: regions
|
||||||
@ -150,6 +154,8 @@ components:
|
|||||||
# groupstyle:
|
# groupstyle:
|
||||||
# MyNation:
|
# MyNation:
|
||||||
# strokeColor: "#007F00"
|
# strokeColor: "#007F00"
|
||||||
|
# # Optional - make layer hidden by default
|
||||||
|
# hidebydefault: true
|
||||||
|
|
||||||
#- class: org.dynmap.TestComponent
|
#- class: org.dynmap.TestComponent
|
||||||
# stuff: "This is some configuration-value"
|
# stuff: "This is some configuration-value"
|
||||||
|
@ -35,6 +35,14 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.leaflet-control-layers {
|
||||||
|
background-color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-control-layers:hover {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.leaflet-control-zoom-in {
|
.leaflet-control-zoom-in {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
}
|
}
|
||||||
|
@ -162,12 +162,10 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
|||||||
loadcss('css/regions.css');
|
loadcss('css/regions.css');
|
||||||
var regionType = configuration.name;
|
var regionType = configuration.name;
|
||||||
loadjs('js/regions_' + regionType + '.js', function() {
|
loadjs('js/regions_' + regionType + '.js', function() {
|
||||||
var activeLayer = undefined;
|
configuration.activeLayer = undefined;
|
||||||
function undraw() {
|
function undraw() {
|
||||||
if (activeLayer) {
|
if (configuration.activeLayer) {
|
||||||
dynmap.layercontrol.removeLayer(activeLayer);
|
configuration.activeLayer.clearLayers();
|
||||||
dynmap.map.removeLayer(activeLayer);
|
|
||||||
activeLayer = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function redraw() {
|
function redraw() {
|
||||||
@ -182,15 +180,24 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
|||||||
createOutlineLayer: configuration.use3dregions ? create3DOutlineLayer : create2DOutlineLayer,
|
createOutlineLayer: configuration.use3dregions ? create3DOutlineLayer : create2DOutlineLayer,
|
||||||
getStyle: getStyle,
|
getStyle: getStyle,
|
||||||
result: function(regionsLayer) {
|
result: function(regionsLayer) {
|
||||||
activeLayer = regionsLayer;
|
if(configuration.activeLayer) { /* Not first time */
|
||||||
dynmap.map.addLayer(activeLayer);
|
for(var i in regionsLayer._layers) {
|
||||||
dynmap.layercontrol.addOverlay(activeLayer, regionType);
|
configuration.activeLayer.addLayer(regionsLayer._layers[i]);
|
||||||
|
}
|
||||||
|
regionsLayer.clearLayers();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
configuration.activeLayer = regionsLayer;
|
||||||
|
if(!configuration.hidebydefault)
|
||||||
|
dynmap.map.addLayer(configuration.activeLayer);
|
||||||
|
dynmap.layercontrol.addOverlay(configuration.activeLayer, regionType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(dynmap).bind('mapchanged', redraw);
|
$(dynmap).bind('mapchanged', redraw);
|
||||||
$(dynmap).bind('mapchanging', undraw);
|
$(dynmap).bind('mapchanging', undraw);
|
||||||
redraw();
|
redraw(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user