-
-
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
Add listener to Layer Control for layer.setVisibleLayers #309
Comments
Hey @msamwill I'm aware of this. AGS map service layers (including groups) are in order and use I would prefer the layer control to be self aware of sublayer changes (as is layer visibility) but that's hard with out dynamic layer keeping track of folder ids. I've thought of a couple solutions. I may just end up using Thoughts? |
I think that if you listen for dynamic layer visibleLayers changes, and update the parent/sublayer visibility as follows there shouldn't be an issue:
I'm not sure if this would work, but I had worked with something similar on a different widget at one point. Thoughts? Array.forEach(layer.visibleLayers, Lang.hitch(layer, function( id ) {
setParentIds(id);
}));
function setParentIds( id ) {
if (id !== -1 &&
layer.visibleLayers !== [-1] &&
layer.layerInfos[id].hasOwnProperty('parentLayerId') &&
layer.layerInfos[id].parentLayerId !== -1
) {
LayerControl[id].set('checked', true);
setParentIds( layer.layerInfos[id].parentLayerId);
}
}; |
The TOC control has this functionality. Looks like the code below allows the TOC to sync with other widgets. If something similar can't be done in the Layer Control then a method that allows us to set the visibility would be the next best thing. Thanks! this._visLayerHandler = aspect.after(this.rootLayer, "setVisibleLayers", lang.hitch(this, this._onSetVisibleLayers), true); _onSetVisibleLayers: function(visLayers, doNotRefresh) { |
Ops. Clicked the wrong button. |
@msamwill @roemhildtg Thanks for poking me on this. Needs fixed. |
@btfou sure thing, thanks for the layer control. Its an excellent addition to this |
Thank you for your time on this, love the new layer control. |
It looks like the latest patch works perfectly when Example:
Layer 1 |
@roemhildtg I see where that would be a problem. If LC isn't initialized and the handler wired up I'm not sure how to work around that. I'm under the gun a project. If you want to look at this and possibly submit a PR I'd appreciate it. |
Okay, I'll see what I can do. |
When you said that the "latest patch works" where you referring to 1.3.1? I couldn't find any other patch. I could live with it not checking the map service but still checking the layer. In my case I have a map service with layers that are not grouped and initially all layers are off. I created two widgets that allow users to dynamically label and classify these layers. In the widgets I use setVisibleLayers to turn the layers on/off when the user labels or classifies a selected layer. The layer becomes visible in the map but the service is not checked and neither is the layer. CAMA (Map Service not checked) |
I was referring to the latest patch in the develop branch here: https://github.com/cmv/cmv-app/tree/develop/viewer/js/gis/dijit/LayerControl |
@msamwill The |
Thanks! |
Just in case this helps anyone, I solved the issue I brought up earlier with the on widget startup. I wrapped the setVisibleLayers function call in a ready( Lang.hitch(this, function() {
//for each layer
layer.setVisibleLayers(...);
})); |
Is this corresponds to the feature where checking the child layer it checks the group layer and the parent layer at the same time? |
This issue was related to a custom widget like the one here https://github.com/roemhildtg/CMV_Widgets/tree/master/AppSettings_Widget that call a layers |
When I make a layer visible/invisible in custom widgit the layer control is still unchecked/checked.
The text was updated successfully, but these errors were encountered: