You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
[Android] Layer symbol changes with the zoom #9975
Hi,
from time to time, I have issue with my symbol layers.
When I change the zoom from one level to another, my layer display either the current state or the old state. (The big marker is one unique layer. I only change the marker icon. The blue direction is another layer)
Below are two captures taken with the same application state but at a slightly different zoom level :
Is it a known issue ? I am not able to find any comments about it. I can explain my code as needed.
(Mapbox 5.1.3)
Thanks.
@paulVulog could you share some code how you are changing the icon?
Changing icons like this should be done with zoom functions, an example of this can be found here.
Then I just change the "is_selected" property and I reload the layer. E.G:
List<Feature> updatedList = new ArrayList<>();
for(Feature f : geoJsonSource.querySourceFeatures(null)) {
if(f.getId().contentEquals(feature.getId())) {
f.addBooleanProperty("is_selected", true);
}
updatedList.add(f);
}
//reload the LayerSource
geoJsonSource.setGeoJson(FeatureCollection.fromFeatures(updatedList));
However, I notice the same issue on a simple symbol layer.
I have create a user position layer that display a single icon.
I change the icon position on every GPS fix. From time to times, the icon is not displayed at the right position and changing the zoom display either the current or previous position.
E.G:
map.addSource(new GeoJsonSource(USER_POSITION_SOURCE));
SymbolLayer userPositionLayer = new SymbolLayer(USER_POSITION_LAYER, USER_POSITION_SOURCE).withProperties(iconImage(MARKER_USER_POSITION));
map.addLayer(userPositionLayer);
The best way to achieve this is using a token that refers to a key in your geojson (eg. {keyFromGeojson}). You use the same key to add images to the map with mapboxMap#addImage("keyFromGeojson", bitmap).
An example of this can be found in the mapbox-android-demo app:
I updated our zoom function example #9987 with UX requested. Didn't run into any of the mentioned issues. So I'm going to close this as non-reproducible. Feel free to add more context or create any follow up issues.
re. showing user location, feel free to check out our locaiton layer plugin that uses layers/sources to do the same. You might find the code there usefull to 👀. See here.
@mpuchala Per documentation, "The output type must be number, array<number>, or color".
That said, we need to fix the example, thanks for pointing this out!
Activity
tobrun commentedon Sep 12, 2017
@paulVulog could you share some code how you are changing the icon?
Changing icons like this should be done with zoom functions, an example of this can be found here.
paulVulog commentedon Sep 13, 2017
Hi @tobrun , I use the same kind of code :
Then I just change the "is_selected" property and I reload the layer. E.G:
However, I notice the same issue on a simple symbol layer.
I have create a user position layer that display a single icon.
I change the icon position on every GPS fix. From time to times, the icon is not displayed at the right position and changing the zoom display either the current or previous position.
E.G:
and updated by
In addition, let me know if you have a better way to achieve what I want to do :
tobrun commentedon Sep 13, 2017
The best way to achieve this is using a token that refers to a key in your geojson (eg.
{keyFromGeojson}). You use the same key to add images to the map withmapboxMap#addImage("keyFromGeojson", bitmap).An example of this can be found in the mapbox-android-demo app:
eg. the images shown in gif below are being shown with a single layer: (the cluster items are seperate):
I will work on adding an example of this to the mentioned example here
tobrun commentedon Sep 13, 2017
I updated our zoom function example #9987 with UX requested. Didn't run into any of the mentioned issues. So I'm going to close this as non-reproducible. Feel free to add more context or create any follow up issues.
re. showing user location, feel free to check out our locaiton layer plugin that uses layers/sources to do the same. You might find the code there usefull to 👀. See here.
paulVulog commentedon Sep 13, 2017
Thanks for all the information and links. I will have a look and perhaps have a try with simple Markers too.
adieldev82 commentedon Dec 27, 2017
The same issue

could be seen in the demo app also.
mpuchala commentedon Apr 27, 2018
Guys,
I have an issue related to this topic. I'm trying to prepare an Activity with Symbols dependent of zoom but it seems to be a problem with
Expression. I have also tried your example (https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java#L104)but in both cases I have an error like:
Error setting property: icon-image Type string is not interpolatable.Thanks for help!
CC: @tobrun
LukasPaczos commentedon Apr 30, 2018
@mpuchala Per documentation, "The output type must be
number,array<number>, orcolor".That said, we need to fix the example, thanks for pointing this out!