Comments (7)
@stleusc thanks for the report.
The remove also changes the group pointers, so better not mix them.
We could just add the missing bindings from the add.
from vtm.
but should the group pointers NOT be updated?
Looking at public synchronized void add(int index, Layer layer)
it seems it does bindings for 'groups'.
But mGroupList
is not touched in that case.
I think there is something else missing regarding groups?!
from vtm.
but should the group pointers NOT be updated?
That's why the remove (used with or without groups) should not be used in regular set.
Just copy these lines from regular add.
The regular add(int index, Layer layer) and set(int index, Layer layer) override List methods
and do not use groups (can only use GroupLayer).
For groups must use the extra add(Layer layer, int group) method.
from vtm.
Guess I need to ask in a better way...
IF I plan to add a layer (no group) and then remove it, I would do the follwing:
add(index, layer):
remove(layer);
But that does modify the mGroupList
on remove!
It seems liket that is not correct?!
I understand how I could make set(index, layer)
work but if I just want to remove a layer that still seems to be incorrect or not?
Somehow the generic remove function needs to know if we are in need of messing with mGroupList
. And that is NOT always the case.
from vtm.
But that does modify the mGroupList on remove!
No, the remove does not modify the mGroupList.
Anyway groups should either be used for all levels or not.
Using groups and add layers without group makes no sense.
Better not mix them.
from vtm.
I don't think we understand each other.... I try to explain better.
I want to be able to remove a layer, and at a later time, add a layer.
I call
@Override
public synchronized void add(int index, Layer layer) {
if (mLayerList.contains(layer)) {
log.warn("layer already exists");
return;
}
// bind added layer
if (layer instanceof UpdateListener)
mMap.events.bind((UpdateListener) layer);
if (layer instanceof InputListener)
mMap.input.bind((InputListener) layer);
// add zoom limit to tile manager
if (layer instanceof ZoomLimiter.IZoomLimiter)
((ZoomLimiter.IZoomLimiter) layer).addZoomLimit();
// bind added group layer
if (layer instanceof GroupLayer) {
GroupLayer groupLayer = (GroupLayer) layer;
for (Layer gl : groupLayer.layers) {
if (gl instanceof UpdateListener)
mMap.events.bind((UpdateListener) gl);
if (gl instanceof InputListener)
mMap.input.bind((InputListener) gl);
if (gl instanceof ZoomLimiter.IZoomLimiter)
((ZoomLimiter.IZoomLimiter) gl).addZoomLimit();
}
}
layer.setEnableHandler(mEnableHandler);
mLayerList.add(index, layer);
mDirtyLayers = true;
}
and
@Override
public synchronized Layer remove(int index) {
mDirtyLayers = true;
Layer remove = mLayerList.remove(index);
// unbind removed layer
if (remove instanceof UpdateListener)
mMap.events.unbind((UpdateListener) remove);
if (remove instanceof InputListener)
mMap.input.unbind((InputListener) remove);
// remove zoom limit from tile manager
if (remove instanceof ZoomLimiter.IZoomLimiter)
((ZoomLimiter.IZoomLimiter) remove).removeZoomLimit();
// unbind removed group layer
if (remove instanceof GroupLayer) {
GroupLayer groupLayer = (GroupLayer) remove;
for (Layer gl : groupLayer.layers) {
if (gl instanceof UpdateListener)
mMap.events.unbind((UpdateListener) gl);
if (gl instanceof InputListener)
mMap.input.unbind((InputListener) gl);
if (gl instanceof ZoomLimiter.IZoomLimiter)
((ZoomLimiter.IZoomLimiter) gl).removeZoomLimit();
}
}
~~~ FROM HERE
// update layer group pointers
for (Integer group : mGroupIndex.keySet()) {
int pointer = mGroupIndex.get(group);
if (pointer > index)
mGroupIndex.put(group, pointer - 1);
}
~~~ TO HERE
remove.setEnableHandler(null);
return remove;
}
Why does the second function contain the portion marked? Does that NOT mess with mGroupIndex
?
You said early on, I should NOT call remove followed by an add.
I am confused... I am not using groups. Just those 2 functions.
Does this make more sense now?
from vtm.
Why does the second function contain the portion marked? Does that NOT mess with mGroupIndex?
If layers size changes, the group index should be updated. And like already mentioned:
Anyway groups should either be used for all levels or not.
Using groups and add layers without group makes no sense.
Better not mix them.
So if not using groups there is no problem.
And if using groups, must use them for all layers.
I said we should not call remove / add inside the set,
but just copy the relevant section.
from vtm.
Related Issues (20)
- Implementation in Android
- Roads render bug with Nextzen/Mapzen HOT 2
- NextzenMvtTileSource has a render bug: wrong tile positions (shuffled) on the level 2 zoom. HOT 3
- TileSource: httpFactory by default HOT 2
- Contours for rendertheme
- Bug in UrlTileDataSource HOT 1
- Crashes when using Tilecache HOT 2
- Publish your own rendertheme
- Overlapping transparent polylines produce darker regions HOT 31
- Triangulation issues since release 0.18 HOT 5
- Support HGT for offline hillshading HOT 1
- How to migrate VTM to mapsforge
- How to add strokes to vector lines
- About MapPosition
- vtm-web Gradle 9 HOT 1
- [VTM] offline map loading failure, tileSource.getMapInfo() returning null
- VTM does not run on Android 15 with 16 KB page size HOT 5
- MapBackground flicker HOT 3
- Package org.oscim.theme is accessible from more than one module: vtm, vtm-themes
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 vtm.