Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Port feature state APIs to Native #12413

Closed

Description

@asheemmamoowala

Port of mapbox/mapbox-gl-js#6263.

GL-Native's separation of Style/Render-Style classes requires that the feature state APIs sync changes to the state across threads on platforms that implement async rendering. The port will be more complicated than the SourceCache based implementation in gl-js.

Native SDKs will need to expose feature state APIs on top of the core implementation, and support the feature-state expressions.

cc @tobrun @1ec5 @mollymerp @ansis

Activity

  1. added
    GL JS parityFor feature parity with Mapbox GL JS
    iOSMapbox Maps SDK for iOS
    macOSMapbox Maps SDK for macOS
    AndroidMapbox Maps SDK for Android
    CoreThe cross-platform C++ core, aka mbgl
    on Jul 18, 2018
  2. 1ec5 commented on Jul 18, 2018

    @1ec5
    Contributor

    Native SDKs will need to expose feature state APIs on top of the core implementation, and support the feature-state expressions.

    For the iOS/macOS API, ideally the getter and setter would be added to MGLVectorTileSource, MGLShapeSource, and MGLComputedShapeSource. That would reduce the number of parameters needed for the setter.

    Can the setter accept an MGLFeature returned from a feature querying method? Those features currently lack context such as the containing style layer or source layer: #7162. The GL JS implementation also accepts a “feature identifier” object containing a source, sourceLayer, and id, which would imply a method like -[MGLVectorTileSource setState:forFeatureWithIdentifier:sourceLayerIdentifier:].

    The setter can accept a whole dictionary as state, which is quite unlike most state properties in Cocoa libraries that are typed as enumerations. The closest Cocoa analogy to the concept of “feature state” that I can think of would be the context parameter of -[NSExpression expressionValueWithObject:context:], which is associated with the variable syntax in NSExpression format strings. However, we’ve already repurposed that variable syntax for expression variables and for certain special expressions like $featureIdentifier.

    /cc @fabian-guerra

  3. asheemmamoowala commented on Jul 18, 2018

    @asheemmamoowala
    ContributorAuthor

    @1ec5 I opened #11846 previously to add more context to features returned from the querying methods. If that context can be added to MGLFeature in some way, then that can be the input for the setState: method.

  4. guyinn commented on Aug 2, 2018

    @guyinn

    @jfirebaugh any eta on this?

  5. cammanderson commented on Sep 26, 2018

    @cammanderson

    Looking forward to this one as well!

  6. john-x-u commented on Mar 4, 2019

    @john-x-u

    Hey Mapbox folks – Is there an updated ETA on this?

  7. tmpsantos commented on Mar 26, 2019

    @tmpsantos
    Contributor

    Hey Mapbox folks – Is there an updated ETA on this?

    Hi @JohnnyUX, we are working on reducing the gap between GL Native and GL JS (https://github.com/mapbox/mapbox-gl-native/blob/master/platform/node/test/ignores.json) but this is not the highest priority ATM because normally the use case has to do with hover a cursor over the feature which is not so common on mobile.

  8. 8 remaining items

  9. jmalanen commented on Sep 4, 2019

    @jmalanen
    Contributor

    Adding a screenshot of feature state demo on mbgl-glfw app. The demo implements the same hover effect as this GL-JS example.

    Screenshot from 2019-09-04 15-33-19

  10. tobrun commented on Sep 9, 2019

    @tobrun
    Member

    Assigning @tarigo for the android bindings

  11. assigned and unassigned on Sep 9, 2019
  12. jmalanen commented on Sep 18, 2019

    @jmalanen
    Contributor

    The core part has now been merged (PR #15480).

  13. removed
    CoreThe cross-platform C++ core, aka mbgl
    on Sep 18, 2019
  14. removed their assignment
    on Oct 21, 2019
  15. mattijsf commented on May 7, 2020

    @mattijsf

    Any progress or planning/estimate for this feature? I hope this can be ported to iOS / Android as it is a really nice way to style selection states on top of external data.

  16. LocusLabsGit commented on Aug 17, 2020

    @LocusLabsGit

    It's been two years since this request was filed. Can we get an update?

  17. sedot42 commented on Mar 29, 2021

    @sedot42

    Hi, another seven months passed, would you be able to give us some insight into your roadmap for this, please? This feature would make things so much easier on mobile!

  18. tobrun commented on Mar 29, 2021

    @tobrun
    Member

    This feature is available on the v10.0.0 of the mobile SDKs:

    Public API for Android implementation of MapboxMap#setFeatureState:

      /**
       * Update the state map of a feature within a style source.
       *
       * Update entries in the state map of a given feature within a style source. Only entries listed in the
       * \p state map will be updated. An entry in the feature state map that is not listed in \p state will
       * retain its previous value.
       *
       * Note that updates to feature state are asynchronous, so changes made by this method migth not be
       * immediately visible using getStateFeature().
       *
       * @param sourceId Style source identifier.
       * @param sourceLayerId Style source layer identifier (for multi-layer sources such as vector sources).
       * @param featureId Identifier of the feature whose state should be updated.
       * @param state Map of entries to update with their respective new values.
       */
      fun setFeatureState(
        sourceId: String,
        sourceLayerId: String?,
        featureId: String,
        state: Value
      )

    on iOS it's availlable as mapView.__map.setFeatureState(..)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidMapbox Maps SDK for AndroidGL JS parityFor feature parity with Mapbox GL JSgl-iosiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions