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
Insert MIXED node layers as layer.Group in Map #1018
Insert MIXED node layers as layer.Group in Map #1018
Conversation
@@ -273,14 +276,14 @@ gmf.LayertreeController.prototype.getLayerCaseMixedGroup_ = function(node) { | |||
for (i = 0; i < subNodes.length; i++) { | |||
subNode = subNodes[i]; | |||
// Create all sublayers include wms layers; | |||
layer = this.getLayer(subNode, 1, true); | |||
layer = this.getLayer(subNode, 1, true, node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if all of this is still usefull.
@ger-benjamin is it still usefull to add the Image layers to the group in one shot here, while we could add them when they come from the getLayers
function ?
I think that that's not the right way. ... I write something... |
this.registerLayer_(layer, true); | ||
if (layer instanceof ol.layer.Group) { | ||
layer.getLayers().forEach(function(l) { | ||
this.registerLayer_(l, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, but they are never unregistered
See handleLayersRemove_
I think that the getLayer function should be called only on real "depth 1". And we must export in another function all line after https://github.com/camptocamp/ngeo/blob/master/contribs/gmf/src/directives/layertree.js#L274 Then the function "getLayerCaseMixedGroup_" should call another function that create all child layers, set their visibility, params, etc, then put theme in a layergroup add this layer group in the map and return this group as layer. Perhaps all these operation must be done in a new function The function getLayerCaseNotMixedGroup_ should do the same but for not mixed group perhaps the current result of this one can use the function "addLayerOnMap". In summary, there is no use now to complexifiy call 'manually' (in the gmf layertree) the So,
|
2ed880d
to
aaed0f4
Compare
@ger-benjamin @adube @fgravin |
* Create and return a layer corresponding to the ngeo layertree's node. | ||
* This function will only create a layer for each "top-level" (depth 1) groups. | ||
* | ||
* On "not mixed" type nodes, the returned layer will be an ol.layer.Image (WMS) | ||
* with each name of node's children as LAYERS parameters. | ||
* | ||
* On "mixed" type node, the returned layer will be an ol.layer.Group with | ||
* a collection of layers that corresponds to each children of the node. | ||
* On "mixed" type node, the returned layer will be an ol.layer.Group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
Some minor comments but it looks more to what i expected. Good work thanks. However, you did not manage correctly the permaling changes, read @adube comments cause you are not doing things properly. Also, we must add more tests. |
ddae139
to
3b216e0
Compare
Ok looks good. |
gmf.LayertreeController.prototype.prepareLayer_ = function(node, layer) { | ||
var type = gmf.Themes.getNodeType(node); | ||
var ids = this.getNodeIds_(node); | ||
if (goog.isDefAndNotNull(layer)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the layer can be null
or undefined
, it should be defined as such in the param section above, as such:
@param {?ol.layer.Base=} opt_layer The...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a truthy
comparison should be enough: if (layer) {
I added some minor comments and a major one. Would it also be possible to have a github.io live example to be able to test it ? |
So ? |
The recursion of addition / removal of layers doesn't seem to have been fixed yet, thus why I hadn't tested yet. I did for what's currently available. The setting of properties work, but I can't fully test the example. When trying to reload the page, we get 404 errors. The LayerTree example seems to be missing some CSS too: https://oliviersemet.github.io/ngeo/1011-insert-mixed-node-layer-as-layer-group-in-map/examples/contribs/gmf/layertree.html |
Yeah, you cannot reload apps, because the theme go into path and break the path. So you need to remove everything in path after |
Something's wrong. I toggled off the visibility of all layers, created the url without the theme then used it. I still have one layer visible where it shouldn't be. Here's the url you can test with: https://oliviersemet.github.io/ngeo/1011-insert-mixed-node-layer-as-layer-group-in-map/examples/contribs/gmf/apps/desktop/theme/OSM?lang=fr&baselayer_ref=map&tree_enable_osm_time=false&tree_enable_osm_scale=false&tree_enable_osm_open=false&tree_group_layers_Layers&tree_group_layers_Group |
@olivierSemet is writing tests. We must have tests that cover all of this. |
3b216e0
to
bb67b26
Compare
this.registerLayer_(layer, opt_init); | ||
}, this) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a layer is ol.layer.Group
, the code carries on after looping inside its layers, which means that events are registered for the ol.layer.Group
. Is this needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing visibility at group level is possible so I would say yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.
I closely supervised the gmf layer tree refining. I think it is a very good improvment, thanks @olivierSemet Very important to add test, really appreciable. |
Related to #1011
PING @fgravin