Skip to content

Conversation

@pjleonard37
Copy link
Contributor

@pjleonard37 pjleonard37 commented Oct 24, 2024

What does this pull request do?

This PR introduces the experimental Interactions API introduced on iOS and Android in 11.8.0-beta.1. Specifically it:

  • Introduces the experimental MapboxMap.addInteractions method, which allows you to add interactions to the map.
    • Introduces TapInteraction and LongTapInteraction, which allow you to add tap and longTap interactions to the map.
    • Introduces FeaturesetDescriptor -- and convenience descriptors for StandardBuildings, StandardPOIs, and StandardPlaceLabels -- which allow you to describe the Featuresets you want Interactions to target.
  • Introduces new methods for queryRenderedFeatures, querySourceFeatures, setFeatureState, getFeatureState, removeFeatureState, resetFeatureState and adds interfaces for iOS and Android
  • Adds all necessary extensions for conversions on iOS and Android
  • Adds an example showing how to query features in featuresets and set feature states.
  • Adds necessary Turf adapters
  • Adds tests
Simulator.Screen.Recording.-.iPhone.16.-.2025-01-08.at.19.57.40.mp4

Work for another PR:

  • Tests which use a mocked interaction
  • Expand on current example to better show use cases for API

What is the motivation and context behind this change?

  • Platform alignment and enable Interactive Features

Pull request checklist:

  • Add a changelog entry.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add documentation comments for any added or updated public APIs.

@pjleonard37 pjleonard37 changed the title Introduce Featuresets and Interactions Introduce Featuresets, QRF, QSF, FS methods Oct 25, 2024
@pjleonard37 pjleonard37 marked this pull request as ready for review October 25, 2024 02:37
@pjleonard37 pjleonard37 requested a review from a team as a code owner October 25, 2024 02:37
@pjleonard37 pjleonard37 requested a review from maios October 25, 2024 02:38
Copy link

@persidskiy persidskiy left a comment

Choose a reason for hiding this comment

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

some small bits of review

@pjleonard37 pjleonard37 force-pushed the MAPSFLT-232-interactive-features branch 2 times, most recently from 2db19c7 to 0ae5762 Compare January 8, 2025 23:41
@pjleonard37 pjleonard37 changed the title Introduce Featuresets, QRF, QSF, FS methods Introduce Interactions API Jan 9, 2025
@pjleonard37 pjleonard37 force-pushed the MAPSFLT-232-interactive-features branch from 62026a5 to ff14167 Compare January 10, 2025 00:06

/// Add an interaction
@experimental
void addInteraction(Interaction interaction, OnInteraction action) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evil159 -- I'd appreciate a particularly thorough review of this section (setting up the listener and message channel. I model it broadly after our approach to gestures, but would welcome any suggested improvements. What do you think of this system of using both _InteractionListener and _InteractionsList?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the limitations - I think this is perfectly fine way to do it(it is also probably the only way to do it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the only thing that is missing here is the ability to remove interaction.

Interaction interaction, int interactionID) async {
try {
return _channel
.invokeMethod('interactions#add_interaction', <String, dynamic>{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evil159 - any better approach here you can think of?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be a way to go to define an internal structure in pigeon templates to carry all of this data and define a method that accepts this structure. It will not change much conceptually, but at least basics(serialization, message sending) will be handled by Pigeon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's a good improvement -- I'll ticket it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this out in the latest commit with the creation of _InteractionPigeon. I'm curious to hear your thoughts on this. I think it cleans up the platform code just a bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... I don't see the reason to wrap interaction into _InteractionPigeon anymore(not sure why I didn't suggest it in the first place, sorry), we can just pass _Interaction itself, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't pass _Interaction because it has types which are not supported by MessageCodec. Specifically: FeaturesetDescriptor and _InteractionType.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, they've changed the way objects are encoded/decoded lately, you can make it work passing the _Interaction type to a pigeon-generated method, but yeah, it won't work out of box when using custom channels.


/// Add an interaction
@experimental
void addInteraction(Interaction interaction, OnInteraction action) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the limitations - I think this is perfectly fine way to do it(it is also probably the only way to do it :)


/// Add an interaction
@experimental
void addInteraction(Interaction interaction, OnInteraction action) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the only thing that is missing here is the ability to remove interaction.

@pjleonard37 pjleonard37 force-pushed the MAPSFLT-232-interactive-features branch from 1d137f1 to fecfbaf Compare January 28, 2025 20:58
Copy link
Contributor

@evil159 evil159 left a comment

Choose a reason for hiding this comment

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

I have to admit I didn't go through the whole PR after recent changes, instead I've reviewed the parts that were changed since and they look good, thank you @pjleonard37 for the effort!

@pjleonard37 pjleonard37 merged commit 178297d into main Jan 29, 2025
6 checks passed
@pjleonard37 pjleonard37 deleted the MAPSFLT-232-interactive-features branch January 29, 2025 13:14
evil159 added a commit that referenced this pull request Feb 3, 2025
* Update README.md for viewport support (#841)

* Update README.md (#837) (#842)

it is not nullable
and it is Point object

Co-authored-by: shinriyo <shinriyo@gmail.com>

* Align tap propagation behavior on Android and iOS. (#847)

* Introduce Interactions API (#748)

* Initial implementation of QRF and Featurestate

* Add Standard experimental, build out Android

* Finish up Android interfaces, general cleanup

* Linting updates

* Additional lint edits

* Clean up type conversions, restore tests

* Update for linting

* Change toValue back

* Update example, some docs cleanup

* Revert

* Build out geometries

* Address review feedback

* Add framework for typed interactions

* Update generated code

* Add map.addInteraction, add Standard featuresets

* Update for sanity check

* Remove viewport query, general cleanup

* Update viewport QRF implementation

* Remove FeaturesetQueryTarget, minor updates from review

* Update Android interface, some formatting

* Make Interactions internal, update implementation

* Initial generics implementation

* Update Podfile

* Update to move _Interactions internal

* Update error handling and interfaces

* Update for lint

* Move interaction to pigeon generation

* Expand use of generics, rename

---------

Co-authored-by: Release SDK bot for Maps SDK team <maps_sdk_ios@mapbox.com>

* Bump platform SDKs version (#855)

* Bump SDK version to 2.6.0-rc.1 (#856)

---------

Co-authored-by: Patrick Leonard <pjleonard37@users.noreply.github.com>
Co-authored-by: shinriyo <shinriyo@gmail.com>
Co-authored-by: Release SDK bot for Maps SDK team <maps_sdk_ios@mapbox.com>
brandon-watkins-avcrm pushed a commit to brandon-watkins-avcrm/mapbox-maps-flutter that referenced this pull request Mar 27, 2025
* Initial implementation of QRF and Featurestate

* Add Standard experimental, build out Android

* Finish up Android interfaces, general cleanup

* Linting updates

* Additional lint edits

* Clean up type conversions, restore tests

* Update for linting

* Change toValue back

* Update example, some docs cleanup

* Revert

* Build out geometries

* Address review feedback

* Add framework for typed interactions

* Update generated code

* Add map.addInteraction, add Standard featuresets

* Update for sanity check

* Remove viewport query, general cleanup

* Update viewport QRF implementation

* Remove FeaturesetQueryTarget, minor updates from review

* Update Android interface, some formatting

* Make Interactions internal, update implementation

* Initial generics implementation

* Update Podfile

* Update to move _Interactions internal

* Update error handling and interfaces

* Update for lint

* Move interaction to pigeon generation

* Expand use of generics, rename

---------

Co-authored-by: Release SDK bot for Maps SDK team <maps_sdk_ios@mapbox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants