Skip to content

Commit

Permalink
fix(layer-selector): error for permanent offscale
Browse files Browse the repository at this point in the history
Layers which are only visible completely outside of the zoom range of
the map are now set to an error state.

Closes #8634
  • Loading branch information
alyec committed May 5, 2015
1 parent 6ec2c07 commit 4adc2f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/js/RAMP/Modules/filterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ define([
*/
function setLayerOffScaleState(layerId) {
var visibleLayers = RampMap.getVisibleLayers(),
invisibleLayers = RampMap.getInvisibleLayers();
invisibleLayers = RampMap.getInvisibleLayers(),
layer = RAMP.layerRegistry[layerId];

function filterLayerIds(layers) {
layers = layers
Expand Down Expand Up @@ -883,7 +884,12 @@ define([
}

if (invisibleLayers.contains(layerId)) {
setLayerState(invisibleLayers, LayerItem.state.OFF_SCALE, true);
if (layer && RampMap.layerInLODRange(layer.maxScale, layer.minScale)) {
setLayerState(invisibleLayers, LayerItem.state.OFF_SCALE, true);
} else {
setLayerState(layerId, LayerItem.state.ERROR, { notices: { error: { message: i18n.t("addDataset.error.messageFeatureOutsideZoomRange") } } });
}

}
}

Expand Down
9 changes: 5 additions & 4 deletions src/js/RAMP/Modules/layerLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ define([
//object to make state decisions
map.addLayer(layer, insertIdx);

//sometimes the ESRI api will kick a layer out of the map if it errors after the add process.
//store a pointer here so we can find it (and it's information)
// TODO - this write to layer registry should be refactored into a call to state manager
RAMP.layerRegistry[layer.id] = layer;

// publish LAYER_ADDED event for every user-added layer
topic.publish(EventManager.LayerLoader.LAYER_ADDED, { layer: layer });

Expand Down Expand Up @@ -260,10 +265,6 @@ define([
}
layer.ramp.load.inLS = true;

//sometimes the ESRI api will kick a layer out of the map if it errors after the add process.
//store a pointer here so we can find it (and it's information)
RAMP.layerRegistry[layer.id] = layer;

//this will force a recreation of the highlighting graphic group.
//if not done, can cause mouse interactions to get messy if adding more than
//one layer at one time
Expand Down

0 comments on commit 4adc2f1

Please sign in to comment.