1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/**
* APIMethod: updateMap
* Cycles through the loaded data and makes
* the necessary calls to the Map object such that that the map's
* visual state corresponds to what the user has selected in the control
* Does not take into account base layers.
*/
updateMap: function() {
var mxz= typeof(this.map.baseLayer.minZoomLevel)=='number'?
this.map.baseLayer.minZoomLevel
: Number.NaN;
var mnz= typeof(this.map.baseLayer.maxZoomLevel)=='number'?
this.map.baseLayer.maxZoomLevel
: Number.NaN;
var changeZoom= -1;
// loop over layers to fix min/max if necessary
if (!isNaN(mxz) && !isNaN(mnz)) {
for (var i= 0, len= this.dataLayers.length; i<len; i++) {
var layerEntry= this.dataLayers[i];
if (layerEntry.inputElem.checked) {
if (typeof(layerEntry.layer.minZoomLevel)=='number' &&
layerEntry.layer.minZoomLevel<mnz) {
mnz= layerEntry.layer.minZoomLevel;
}
if (typeof(layerEntry.layer.maxZoomLevel)=='number' &&
layerEntry.layer.maxZoomLevel>mxz) {
mxz= layerEntry.layer.maxZoomLevel;
}
}
}
if (mnz<=mxz) {
if (mxz<this.map.baseLayer.maxZoomLevel && this.map.getZoom()>mxz) {
changeZoom= mxz;
}
if (mnz>this.map.baseLayer.minZoomLevel && this.map.getZoom()<mnz) {
changeZoom= mnz;
}
if (this.map.baseLayer.minZoomLevel!=mnz) {
this.map.baseLayer.minZoomLevel= mnz;
this.map.baseLayer.minResolution= this.map.baseLayer.resolutions[mnz];
this.map.baseLayer.minScale= this.map.baseLayer.scales[mnz];
}
if (this.map.baseLayer.maxZoomLevel!=mxz) {
this.map.baseLayer.maxZoomLevel= mxz;
this.map.baseLayer.maxResolution= this.map.baseLayer.resolutions[mxz];
this.map.baseLayer.maxScale= this.map.baseLayer.scales[mxz];
}
}
}
// set the correct visibilities for the overlays
for (var i= 0, len= this.dataLayers.length; i<len; i++) {
var layerEntry= this.dataLayers[i];
layerEntry.layer.setVisibility(layerEntry.inputElem.checked);
}
if (changeZoom!=-1) {
this.map.moveTo(null,changeZoom);
}
}, |
Partager