Comments (5)
Temporary fix:
Instead of inserting at specified idx, always insert at 0. It does not work for first level nodes so i ended up with quite ugly solution:
if (parentNode == me.getRootNode()) {
parentNode.appendChild(layerNode);
}else{
parentNode.insertChild(0, layerNode);
}
from geoext.
Ignore above fix. It works only when tree is initialy rendered and won't work when a layer is inserted at specified position later.
from geoext.
Thanks for your effort on this. Your description makes for some pretty good test cases that we should add as specs to related components. This will make it easier to fix this problem once and for all. I may have some time on the weekend to look into this. It would be even better if you could provide a PR. Even only some test cases would come a long way really. Anyway, thanks for your participation.
from geoext.
Hi bentrm,
I can provide PR and test cases but only after the weekend. If you have time now and don't want to wait i can give some hints of what i have learned.
I ended with solution that seems to work for me but i am not sure if it covers all the cases (i did some tests only for inverseLayerOrder). So here is what i did:
In LayersTree constructor i removed the inverseordering from Ext.each. That is why my previous code was not working for top level nodes.
Ext.each(collection.getArray(), function(layer) {
me.addLayerNode(layer);
}, me);
Now i separated the initial tree creation and the tree modification caused by adding layers to map later by adding another parameter to addLayerNode:
addLayerNode:function(layerOrGroup, isInsert)
After introducing second parameter it is good idea to rewrite all the each function using addLayerNode like:
layerOrGroup.getLayers().forEach(me.addLayerNode, me);
as they pass idx as second parameter (it doesn't matter if we do boolean check though)
In addLayerNode method:
if (me.inverseLayerOrder) {
if (isInsert === true) {
var totalInGroup = group.getLayers().getLength();
layerIdx = totalInGroup - layerIdx - 1;
parentNode.insertChild(layerIdx, layerNode);
}else{
parentNode.insertChild(0, layerNode);
}
}
in case of inserting/adding layers to existing tree, current code works just fine, so i execute it if isInsert is set to true, oterwise (during tree initial build) layer should be always inserted at 0 :
And the last point, in method onLayerCollectionAdd i added isInsert set to true:
me.addLayerNode(layerOrGroup, true);
Again as i needed quick fix for inverseLayerOrder case i did not test if the code works for standardLayerOrder (bottom layer on top of tree). I can do some testing after the weekend and maybe come up with better solution.
from geoext.
The solution is much simpler than i originally thought. To fix the problem we have to iterate through array of layers backwards. This is already done this way, but only for direct children of root node.
from geoext.
Related Issues (20)
- Two-way binding between a layer and store in GeoExt.data.store.Features HOT 17
- example link not working HOT 3
- geoext4 with ExtJS v7.0.0 and OpenLayers v6.4.3 HOT 1
- Add GitHubActions CI
- Fix build of gh-pages to include GeoExt Sencha build HOT 1
- Subdirectory to tree.Panel HOT 4
- next geoext release with openlayers 6.5 HOT 9
- Increase line width in eslint
- update geoext page with v4
- GeoExt.selection.FeatureModelMixin event handlers not added
- Add GeoExt 4.0 to website and README
- WFS Store Debouncing calling server twice HOT 1
- Some broken examples HOT 2
- OverviewMap component not working after updating OpenLayers HOT 5
- GeoExt.data.WFSCapabilitiesStore and GeoExt.data.WMSCapabilitiesStore
- Production build of GeoExt HOT 2
- vector tiles problem in Geoext4? HOT 2
- Error when clearing a FeatureCollection
- Just for information purposes: ExtJs 7.5.0.5 and GeoExt4 and OpenLayers 6.7.0 is working, but 6.8.0 upwards not
- Linting action not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geoext.