-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support to add & remove layer(s) from the Layer Control #500
Added support to add & remove layer(s) from the Layer Control #500
Conversation
//add new layer function _setupSampleLayer(args) { var layer = args.layer; var target = args.target; layer.setVisibility(true); layer.opacity = 1; for (var i = 0; i < 8; i++) { var eLayerInfo = layer.layerInfos[i]; eLayerInfo.defaultVisibility = true } }; function _loadSampleLayer() { var imageParameters = new esri.layers.ImageParameters(); imageParameters.layerIds = [0,1,2,3,4,5,6,7]; imageParameters.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://<server>/arcgis/rest/services/<service>/MapServer", {id: "MyMapService", visible : true, imageParameters : imageParameters } ); layer.on("load", function(args) { _setupSampleLayer(args); }); layer.on("error", function(args) { debugger; }); this.app.map.addLayer(layer); this.app.map.on("layer-add-result", function(args) { var layer = args.layer; var error = args.error; var layerInfo = { title : "My Sample Title", type : "dynamic", layer : layer } dojo.publish('layerControl/addLayerControls', [[layerInfo]]); }); } //remove layer dojo.publish("layerControl/removeLayerControls", [["My Sample Title"]])
Travis check should pass once PR #499 is merged into the develop branch and then this branch is updated from develop branch. |
#499 merged. Please fix so we can review. |
@AlexThomasEOG If you merge the current develop branch from cmv-app into the branch in your repo, then once this PR is reviewed we can commit/merge the changes back into cmv-app repo. Thanks! |
standardized the format of the .js file
@AlexThomasEOG I see you've adapted the new code to match our code style rules per the travis build process. Much thanks for that extra effort. Looks like the PR is ready to merge. @btfou: What do you think of these enhancements to LayerControl widget? |
@AlexThomasEOG On Friday I posted a suggested code addition in the gitter chat in case you missed it. |
Got it, let me take a look and add it in tonight. I have some other changes that will be helpful with dynamic map services that use custom renderers in the dynamicLayers parameter for ExportMap |
Sounds like the second part is a separate PR. |
Ah right. In that case let me keep the changes just limited to layerControl api |
…ntrols when necessary var myLayer; function _setupSampleLayer(args) { var layer = args.layer; var target = args.target; layer.setVisibility(true); layer.opacity = 1; for (var i = 0; i < 8; i++) { var eLayerInfo = layer.layerInfos[i]; eLayerInfo.defaultVisibility = true } }; function _loadSampleLayer() { var imageParameters = new esri.layers.ImageParameters(); imageParameters.layerIds = [0,1,2,3,4,5,6,7]; imageParameters.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; myLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://hougissrv02:6080/arcgis/rest/services/Integrations_iApps/DEN_iAppsBase/MapServer", {id: "MyMapService", visible : true, imageParameters : imageParameters } ); myLayer.on("load", function(args) { _setupSampleLayer(args); }); myLayer.on("error", function(args) { debugger; }); this.app.map.addLayer(myLayer); this.app.map.on("layer-add-result", function(args) { var layer = args.layer; var error = args.error; var layerInfo = { title : "My Sample Title", type : "dynamic", layer : layer } dojo.publish('layerControl/addLayerControls', [[layerInfo]]); }); } dojo.publish("layerControl/removeLayerControls", [[myLayer]])
var myLayer; function _setupSampleLayer(args) { var layer = args.layer; var target = args.target; layer.setVisibility(true); layer.opacity = 1; for (var i = 0; i < 8; i++) { var eLayerInfo = layer.layerInfos[i]; eLayerInfo.defaultVisibility = true } }; function _loadSampleLayer(requestedPosition) { var imageParameters = new esri.layers.ImageParameters(); imageParameters.layerIds = [0,1,2,3,4,5,6,7]; imageParameters.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW; myLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http:///arcgis/rest/services//MapServer", {id: "MyMapService", visible : true, imageParameters : imageParameters } ); myLayer.on("load", function(args) { _setupSampleLayer(args); }); myLayer.on("error", function(args) { debugger; }); this.app.map.addLayer(myLayer ); var signal = this.app.map.on("layer-add-result", function(args) { signal.remove() var layer = args.layer; var error = args.error; var layerInfo = { title : "My Sample Title", type : "dynamic", layer : layer, position : requestedPosition } dojo.publish('layerControl/addLayerControls', [[layerInfo]]); }); } // function _removeSampleLayer() { dojo.publish("layerControl/removeLayerControls", [[myLayer]]); this.app.map.removeLayer(myLayer); } _loadSampleLayer(0); _removeSampleLayer(); //pause _loadSampleLayer(1); _removeSampleLayer(); //pause _loadSampleLayer(2); _removeSampleLayer();
var myLayer;
function _setupSampleLayer(args) {
var layer = args.layer;
var target = args.target;
layer.setVisibility(true);
layer.opacity = 1;
for (var i = 0; i < 8; i++) {
var eLayerInfo = layer.layerInfos[i];
eLayerInfo.defaultVisibility = true
}
};
function _loadSampleLayer(requestedPosition) {
var imageParameters = new esri.layers.ImageParameters();
imageParameters.layerIds = [0,1,2,3,4,5,6,7];
imageParameters.layerOption =
esri.layers.ImageParameters.LAYER_OPTION_SHOW;
myLayer = new
esri.layers.ArcGISDynamicMapServiceLayer("http:///arcgis/rest/services//MapServer",
{id: "MyMapService",
visible : true,
imageParameters : imageParameters
}
);
myLayer.on("load", function(args) {
_setupSampleLayer(args);
});
myLayer.on("error", function(args) {
debugger;
});
this.app.map.addLayer(myLayer );
var signal = this.app.map.on("layer-add-result", function(args) {
signal.remove()
var layer = args.layer;
var error = args.error;
var layerInfo = {
title : "My Sample Title",
type : "dynamic",
layer : layer,
position : requestedPosition
}
dojo.publish('layerControl/addLayerControls', [[layerInfo]]);
});
}
//
function _removeSampleLayer() {
dojo.publish("layerControl/removeLayerControls", [[myLayer]]);
this.app.map.removeLayer(myLayer);
}
_loadSampleLayer(0);
_removeSampleLayer();
//pause
_loadSampleLayer(1);
_removeSampleLayer();
//pause
_loadSampleLayer(2);
_removeSampleLayer(); |
@btfou ping |
Added support to add & remove layer(s) from the Layer Control
//add new layer
function _setupSampleLayer(args) {
var layer = args.layer;
var target = args.target;
layer.setVisibility(true);
layer.opacity = 1;
for (var i = 0; i < 8; i++) {
var eLayerInfo = layer.layerInfos[i];
eLayerInfo.defaultVisibility = true
}
};
function _loadSampleLayer() {
var imageParameters = new esri.layers.ImageParameters();
imageParameters.layerIds = [0,1,2,3,4,5,6,7];
imageParameters.layerOption =
esri.layers.ImageParameters.LAYER_OPTION_SHOW;
var layer = new
esri.layers.ArcGISDynamicMapServiceLayer("http:///arcgis/rest/services//MapServer",
{id: "MyMapService",
visible : true,
imageParameters : imageParameters
}
);
layer.on("load", function(args) {
_setupSampleLayer(args);
});
layer.on("error", function(args) {
debugger;
});
this.app.map.addLayer(layer);
this.app.map.on("layer-add-result", function(args) {
var layer = args.layer;
var error = args.error;
var layerInfo = {
title : "My Sample Title",
type : "dynamic",
layer : layer
}
dojo.publish('layerControl/addLayerControls', [[layerInfo]]);
});
}
//remove layer
dojo.publish("layerControl/removeLayerControls", [["My Sample Title"]])