-
-
Notifications
You must be signed in to change notification settings - Fork 439
Add feature state functionality to iOS #3858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Bloaty Results (iOS) 🐋Compared to main Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-3858-compared-to-main.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements feature state functionality for iOS MapLibre, enabling dynamic styling of map features based on user-defined state properties. The implementation adds APIs to set, get, and remove feature state, along with a comprehensive example demonstrating interactive map styling.
- Adds feature state management methods to MLNMapView with support for both convenience and explicit parameter APIs
- Creates a complete Swift example showcasing interactive US state selection with feature-state expressions
- Updates documentation with comprehensive guides and API references for the new functionality
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| platform/ios/src/MLNMapView.mm | Implements core feature state methods with MBGL integration and state conversion |
| platform/ios/src/MLNMapView.h | Adds public API declarations and comprehensive documentation for feature state methods |
| platform/ios/app-swift/Sources/FeatureStateExample.swift | Complete interactive example demonstrating feature state usage with US states data |
| platform/ios/app-swift/Sources/MapLibreNavigationView.swift | Adds navigation link to the new feature state example |
| platform/ios/MapLibre.docc/FeatureStateExample.md | Comprehensive documentation with code examples and best practices |
| platform/ios/MapLibre.docc/MapLibre.md | Updates main documentation index to include feature state example |
| platform/ios/MapLibre.docc/ObserverExample.md | Minor code formatting improvement in observer example |
| platform/ios/MapLibre.docc/ActionJournalExample.md | Adds rendering stats report interval configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| return; | ||
| } | ||
|
|
||
| NSString *featureID = [NSString stringWithFormat:@"%@", feature.identifier]; |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could crash if feature.identifier is nil. The stringWithFormat will convert nil to '(null)' string, which may not be the intended behavior for feature identification.
| return nil; | ||
| } | ||
|
|
||
| NSString *featureID = [NSString stringWithFormat:@"%@", feature.identifier]; |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could crash if feature.identifier is nil. The stringWithFormat will convert nil to '(null)' string, which may not be the intended behavior for feature identification.
| return; | ||
| } | ||
|
|
||
| NSString *featureID = [NSString stringWithFormat:@"%@", feature.identifier]; |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could crash if feature.identifier is nil. The stringWithFormat will convert nil to '(null)' string, which may not be the intended behavior for feature identification.
| mapView.setFeatureState(feature, sourceID: "states", state: ["selected": true]) | ||
|
|
||
| // Set feature state using explicit identifiers | ||
| mapView.setFeatureState("states", sourceLayer: nil, featureID: "54", state: ["selected": true]) |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method call is incorrect. The first parameter should be sourceID, but the method name suggests it should be setFeatureStateForSource. The correct call should be mapView.setFeatureStateForSource(\"states\", sourceLayer: nil, featureID: \"54\", state: [\"selected\": true]).
| mapView.setFeatureState("states", sourceLayer: nil, featureID: "54", state: ["selected": true]) | |
| mapView.setFeatureStateForSource("states", sourceLayer: nil, featureID: "54", state: ["selected": true]) |
| let isSelected = currentState?["selected"] as? Bool ?? false | ||
|
|
||
| // Get state using explicit identifiers | ||
| let state = mapView.getFeatureState("states", sourceLayer: nil, featureID: "54") |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method call is incorrect. The method name should be getFeatureStateForSource. The correct call should be mapView.getFeatureStateForSource(\"states\", sourceLayer: nil, featureID: \"54\").
| let state = mapView.getFeatureState("states", sourceLayer: nil, featureID: "54") | |
| let state = mapView.getFeatureStateForSource("states", sourceLayer: nil, featureID: "54") |
| - ``MLNMapView/setFeatureState:sourceLayer:featureID:state:`` - Set state with explicit identifiers | ||
| - ``MLNMapView/getFeatureState:sourceID:`` - Get current state of a feature | ||
| - ``MLNMapView/getFeatureState:sourceLayer:featureID:`` - Get state with explicit identifiers | ||
| - ``MLNMapView/removeFeatureState:sourceID:stateKey:`` - Remove state from a feature | ||
| - ``MLNMapView/removeFeatureState:sourceLayer:featureID:stateKey:`` - Remove state with explicit identifiers |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation references are incorrect for the explicit identifier methods. Lines 216, 218, and 220 should reference setFeatureStateForSource:sourceLayer:featureID:state:, getFeatureStateForSource:sourceLayer:featureID:, and removeFeatureStateForSource:sourceLayer:featureID:stateKey: respectively.
| - ``MLNMapView/setFeatureState:sourceLayer:featureID:state:`` - Set state with explicit identifiers | |
| - ``MLNMapView/getFeatureState:sourceID:`` - Get current state of a feature | |
| - ``MLNMapView/getFeatureState:sourceLayer:featureID:`` - Get state with explicit identifiers | |
| - ``MLNMapView/removeFeatureState:sourceID:stateKey:`` - Remove state from a feature | |
| - ``MLNMapView/removeFeatureState:sourceLayer:featureID:stateKey:`` - Remove state with explicit identifiers | |
| - ``MLNMapView/setFeatureStateForSource:sourceLayer:featureID:state:`` - Set state with explicit identifiers | |
| - ``MLNMapView/getFeatureState:sourceID:`` - Get current state of a feature | |
| - ``MLNMapView/getFeatureStateForSource:sourceLayer:featureID:`` - Get state with explicit identifiers | |
| - ``MLNMapView/removeFeatureState:sourceID:stateKey:`` - Remove state from a feature | |
| - ``MLNMapView/removeFeatureStateForSource:sourceLayer:featureID:stateKey:`` - Remove state with explicit identifiers |
Implements #1698 for iOS.
feature-statewas already implemented in the core.Also ports the GLFW example to the Swift-based example app.
FeatureState.mp4
TODO: