Skip to content
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

Merged

Conversation

AlexThomasEOG
Copy link
Contributor

//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"]])

//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"]])
@tmcgee
Copy link
Member

tmcgee commented Jan 14, 2016

Travis check should pass once PR #499 is merged into the develop branch and then this branch is updated from develop branch.

@DavidSpriggs
Copy link
Member

#499 merged. Please fix so we can review.

@tmcgee tmcgee added this to the v1.4.0 milestone Jan 14, 2016
@tmcgee
Copy link
Member

tmcgee commented Jan 14, 2016

@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!

@tmcgee
Copy link
Member

tmcgee commented Jan 14, 2016

@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?

@tmcgee
Copy link
Member

tmcgee commented Jan 19, 2016

@AlexThomasEOG On Friday I posted a suggested code addition in the gitter chat in case you missed it.

@AlexThomasEOG
Copy link
Contributor Author

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

@tmcgee
Copy link
Member

tmcgee commented Jan 19, 2016

Sounds like the second part is a separate PR.

@AlexThomasEOG
Copy link
Contributor Author

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();
@AlexThomasEOG
Copy link
Contributor Author

@tmcgee @btfou Should be good now for a review

@AlexThomasEOG
Copy link
Contributor Author

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();

@tmcgee
Copy link
Member

tmcgee commented Jan 28, 2016

@btfou ping

DavidSpriggs added a commit that referenced this pull request Feb 3, 2016
Added support to add & remove layer(s) from the Layer Control
@DavidSpriggs DavidSpriggs merged commit 5df75a5 into cmv:develop Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants