setFeatureState method

dynamic setFeatureState(
  1. dynamic feature,
  2. dynamic state
)

Sets the state of a feature. The state object is merged in with the existing state of the feature. Features are identified by their id attribute, which must be an integer or a string that can be cast to an integer.

@param {Object} feature Feature identifier. Feature objects returned from {@link MapboxMap#queryRenderedFeatures} or event handlers can be used as feature identifiers. @param {string | number} feature.id Unique id of the feature. @param {string} feature.source The Id of the vector source or GeoJSON source for the feature. @param {string} feature.sourceLayer (optional) /// For vector tile sources, the sourceLayer is required.* @param {Object} state A set of key-value pairs. The values should be valid JSON types.

This method requires the feature.id attribute on data sets. For GeoJSON sources without feature ids, set the generateId option in the GeoJSONSourceSpecification to auto-assign them. This option assigns ids based on a feature's index in the source data. If you change feature data using map.getSource('some id').setData(..), you may need to re-apply state taking into account updated id values.

Implementation

setFeatureState(dynamic feature, dynamic state) =>
    jsObject.setFeatureState(feature, state);