Skip to content

feat(ios): add feature state api#4420

Open
MarkusWendorf wants to merge 3 commits into
maplibre:mainfrom
MarkusWendorf:ios-feature-state-source-api
Open

feat(ios): add feature state api#4420
MarkusWendorf wants to merge 3 commits into
maplibre:mainfrom
MarkusWendorf:ios-feature-state-source-api

Conversation

@MarkusWendorf

@MarkusWendorf MarkusWendorf commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Implements feature state for iOS. feature-state was already implemented in the core.

This is an alternative implementation to #3858, deliberately aligned with the API shape that shipped for Android in #4219.

I also added a vector-tile example to Android, so that we now have a GeoJSON example AND a vector-tile example for feature-state on both iOS and Android.

Tests added:

  • platform/ios/test/MLNFeatureStateTests.swift —
    MLNFeatureStateTests.testFeatureStateRoundTrip (integration test through the Swift source
    API).
  • test/api/query.test.cpp — Query.QuerySourceFeatureStates and
    Query.RemoveSourceFeatureState (set/get round-trip and key-/feature-level removal via the
    renderer).
  • test/map/map.test.cpp — Map.FeatureStateChangesRenderedStyle, an end-to-end test asserting
    that a feature-state change actually alters rendered pixel output through a data-driven
    ["case", ["boolean", ["feature-state", "active"], …]] fill-color expression.

Co-authored with AI: Anthropic Fable/Opus 4.8

@MarkusWendorf
MarkusWendorf marked this pull request as ready for review July 20, 2026 21:05
@louwers

louwers commented Jul 20, 2026

Copy link
Copy Markdown
Member

Thanks Markus. I think an implementation that aligns with Android makes more sense.

Will have a look at this tomorrow.

// Toggle the selection state of the tapped feature. Selection is not
// exclusive: any number of states can be selected at the same time.
let isSelected = statesSource.featureState(featureID: featureID)?["selected"] as? Bool ?? false
statesSource.setFeatureState(featureID: featureID, state: ["selected": !isSelected])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@louwers not sure if I jumped the shark here but I assumed your PR is out-dated now that the source centric API from Android was merged.

@MarkusWendorf MarkusWendorf changed the title FeatureState for iOS feat(ios): add feature state api Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4420-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +54% +62.9Mi  +471% +28.1Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-4420-compared-to-legacy.txt

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results ⚡

Benchmark                                                          Time             CPU      Time Old      Time New       CPU Old       CPU New
-----------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                                 +0.0066         +0.0066             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-4420-compared-to-main.txt

@github-actions

Copy link
Copy Markdown
Contributor

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0% +4.30Ki  [ = ]       0    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-4420-compared-to-main.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants