Open FezVrasta opened 10 months ago
Hi @FezVrasta , thank you for the report!
I managed to reproduce the issue locally, but in my case the polygon changes the color if I pan the map for a while after the state update. Can you please confirm if you see the same result?
Internal bug to track https://mapbox.atlassian.net/browse/MAPSNAT-1585
Thanks for the reply. In my case the color never changes.
@FezVrasta Did you try to use "6D9AE" geojson source id? The "composite" is a Mapbox vector source that drives the basemap
I tried both sources (I literally forEach
ed on every available source and run the same logic on each)
Also, the 6D9AE ID changes on each load so, even if it worked, it would not be usable on a production app.
I also wonder why this code returns a state, shouldn't it error if I try to set state on a non-existent feature?
map.setFeatureState(
sourceId: "composite",
//sourceLayerId: "micro-regions_elevation-2p16jz",
featureId: "AD-01_low_high",
state: ["danger_level": 4],
callback: { result in
// This returns `success(<null>)`
print(result)
map.getFeatureState(
sourceId: "composite",
featureId: "AD-01_low_high",
callback: { state in
// This correctly prints `success(["danger_level": 4])`
// but the map style is not updated
print(state)
}
)
}
)
I also wonder why this code returns a state, shouldn't it error if I try to set state on a non-existent feature?
In some cases the geojson can me loaded later than the state is set.
Also, the 6D9AE ID changes on each load so, even if it worked, it would not be usable on a production app.
This may be a reason for your issue, for example you set the feature state for one Source ID, then load a new source with the different ID. The state won't be transferred int this case
This may be a reason for your issue, for example you set the feature state for one Source ID, then load a new source with the different ID. The state won't be transferred int this case
I'm not loading any sources manually, I'm only using the ones baked in the style.
@FezVrasta Hi, can you please check if the issue is resolved in v11.0.0 stable release?
It'll take some time as I'm focusing on other things currently, I'll let you know as soon I test it.
I'm sorry, I realized I won't have time to look into this for the foreseeable future. Feel free to close the issue if you think the bug has been addressed already.
Environment
Observed behavior and steps to reproduce
I have created a custom map style on Mapbox Studio and uploaded a GeoJSON with several multipolygon features, the file looks like this:
I defined a custom styling for the layer I created so that each feature will be colored according to the
danger_level
feature state (1, 2, 3, 4, 5):Now my plan would be to set the
danger_level
for each feature from the iOS SDK, but I can't really find a way to do it.I tried using
setFeatureState
but it has no effect:The code above has no effect, the state seems to be set correctly but no updates happen on the rendered map.
If I also specify the
sourceLayerId
, the secondprint
statement returns an empty dictionary.If I print
map.allSourceIdentifiers
I only see this:My map has two geojson layers, not one, and 6D9AE changes id on each render. I tried using
map.allSourceIdentifiers.last!.id
assourceId
for thesetFeatureState
call but it had no effect.I tried to retrieve the layer with
map.layer(withId: "micro-regions_elevation")
and it correctly returned the layer data:But I still get the same result.
I also tried this alternative fill color formula wit the same result though:
This is my map style ID for reference: mapbox://styles/fezvrasta/clol7m5uj008q01qocvyg1fzx
What am I doing wrong?