Skip to content

Commit

Permalink
Add getFeatureState
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-karajgikar committed Aug 24, 2021
1 parent 3a0e0da commit 1e45642
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Sources/MapboxMaps/Foundation/MapboxMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,24 @@ extension MapboxMap {
state: state)
}

/// Get the state map of a feature within a style source.
///
/// - Note: Updates to feature state are asynchronous, so changes made by other methods might not be immediately visible.
/// - Parameters:
/// - sourceId: Style source identifier.
/// - sourceLayerId: Style source layer identifier (for multi-layer sources such as vector sources).
/// - featureId: Identifier of the feature whose state should be queried.
/// - callback: Feature's state map or an empty map if the feature could not be found.
public func getFeatureState(sourceId: String, sourceLayerId: String? = nil, featureId: String, callback: @escaping (Result<[String: Any], Error>) -> Void) {
__map.getFeatureState(forSourceId: sourceId,
sourceLayerId: sourceLayerId,
featureId: featureId,
callback: coreAPIClosureAdapter(for: callback,
type: NSDictionary.self,
concreteErrorType: MapError.self))
}


/// Removes entries from a feature state object.
/// Remove a specified property or all property from a feature's state object, depending on the value of `stateKey`.
///
Expand All @@ -543,7 +561,7 @@ extension MapboxMap {
/// - Parameters:
/// - sourceId: The style source identifier
/// - sourceLayerId: The style source layer identifier (for multi-layer sources such as vector sources). Defaults to `nil`.
/// - featureId: The feature identifier of the feature whose state should be removed
/// - featureId: The feature identifier of the feature whose state should be removed.
/// - stateKey: The key of the property to remove. If `nil`, all feature's state object properties are removed. Defaults to `nil`.
public func removeFeatureState(sourceId: String, sourceLayerId: String? = nil, featureId: String, stateKey: String? = nil) {
__map.removeFeatureState(forSourceId: sourceId,
Expand Down

0 comments on commit 1e45642

Please sign in to comment.