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:
|
||||
# homebase:
|
||||
# strokeColor: "#00FF00"
|
||||
# # Optional - make layer hidden by default
|
||||
# hidebydefault: true
|
||||
|
||||
#- class: org.dynmap.regions.RegionsComponent
|
||||
# type: regions
|
||||
@ -122,6 +124,8 @@ components:
|
||||
# groupstyle:
|
||||
# homebase:
|
||||
# strokeColor: "#007F00"
|
||||
# # Optional - make layer hidden by default
|
||||
# hidebydefault: true
|
||||
|
||||
#- class: org.dynmap.regions.RegionsComponent
|
||||
# type: regions
|
||||
@ -150,6 +154,8 @@ components:
|
||||
# groupstyle:
|
||||
# MyNation:
|
||||
# strokeColor: "#007F00"
|
||||
# # Optional - make layer hidden by default
|
||||
# hidebydefault: true
|
||||
|
||||
#- class: org.dynmap.TestComponent
|
||||
# stuff: "This is some configuration-value"
|
||||
|
@ -35,6 +35,14 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.leaflet-control-layers {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-control-layers:hover {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.leaflet-control-zoom-in {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
@ -162,12 +162,10 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
||||
loadcss('css/regions.css');
|
||||
var regionType = configuration.name;
|
||||
loadjs('js/regions_' + regionType + '.js', function() {
|
||||
var activeLayer = undefined;
|
||||
configuration.activeLayer = undefined;
|
||||
function undraw() {
|
||||
if (activeLayer) {
|
||||
dynmap.layercontrol.removeLayer(activeLayer);
|
||||
dynmap.map.removeLayer(activeLayer);
|
||||
activeLayer = undefined;
|
||||
if (configuration.activeLayer) {
|
||||
configuration.activeLayer.clearLayers();
|
||||
}
|
||||
}
|
||||
function redraw() {
|
||||
@ -182,15 +180,24 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
||||
createOutlineLayer: configuration.use3dregions ? create3DOutlineLayer : create2DOutlineLayer,
|
||||
getStyle: getStyle,
|
||||
result: function(regionsLayer) {
|
||||
activeLayer = regionsLayer;
|
||||
dynmap.map.addLayer(activeLayer);
|
||||
dynmap.layercontrol.addOverlay(activeLayer, regionType);
|
||||
if(configuration.activeLayer) { /* Not first time */
|
||||
for(var i in regionsLayer._layers) {
|
||||
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('mapchanging', undraw);
|
||||
redraw();
|
||||
redraw(true);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user