-
Notifications
You must be signed in to change notification settings - Fork 183
Introduce Interactions API #748
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
Conversation
android/src/main/kotlin/com/mapbox/maps/mapbox_maps/Extentions.kt
Outdated
Show resolved
Hide resolved
android/src/main/kotlin/com/mapbox/maps/mapbox_maps/Extentions.kt
Outdated
Show resolved
Hide resolved
persidskiy
left a comment
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.
some small bits of review
android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapInterfaceController.kt
Outdated
Show resolved
Hide resolved
android/src/main/kotlin/com/mapbox/maps/mapbox_maps/Extentions.kt
Outdated
Show resolved
Hide resolved
2db19c7 to
0ae5762
Compare
62026a5 to
ff14167
Compare
ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/MapboxMapController.swift
Show resolved
Hide resolved
lib/src/mapbox_map.dart
Outdated
|
|
||
| /// Add an interaction | ||
| @experimental | ||
| void addInteraction(Interaction interaction, OnInteraction action) { |
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.
@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?
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.
Given the limitations - I think this is perfectly fine way to do it(it is also probably the only way to do it :)
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.
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>{ |
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.
@evil159 - any better approach here you can think of?
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.
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.
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.
I think that's a good improvement -- I'll ticket it
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.
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.
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.
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?
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.
We can't pass _Interaction because it has types which are not supported by MessageCodec. Specifically: FeaturesetDescriptor and _InteractionType.
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.
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.
ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/MapInterfaceController.swift
Show resolved
Hide resolved
ios/mapbox_maps_flutter/Sources/mapbox_maps_flutter/Classes/MapInterfaceController.swift
Show resolved
Hide resolved
lib/src/mapbox_map.dart
Outdated
|
|
||
| /// Add an interaction | ||
| @experimental | ||
| void addInteraction(Interaction interaction, OnInteraction action) { |
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.
Given the limitations - I think this is perfectly fine way to do it(it is also probably the only way to do it :)
lib/src/mapbox_map.dart
Outdated
|
|
||
| /// Add an interaction | ||
| @experimental | ||
| void addInteraction(Interaction interaction, OnInteraction action) { |
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.
I think the only thing that is missing here is the ability to remove interaction.
1d137f1 to
fecfbaf
Compare
evil159
left a comment
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.
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!
* 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>
* 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>
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:
MapboxMap.addInteractionsmethod, which allows you to add interactions to the map.TapInteractionandLongTapInteraction, which allow you to add tap and longTap interactions to the map.FeaturesetDescriptor-- and convenience descriptors forStandardBuildings,StandardPOIs, andStandardPlaceLabels-- which allow you to describe theFeaturesets you wantInteractionsto target.queryRenderedFeatures,querySourceFeatures,setFeatureState,getFeatureState,removeFeatureState,resetFeatureStateand adds interfaces for iOS and AndroidSimulator.Screen.Recording.-.iPhone.16.-.2025-01-08.at.19.57.40.mp4
Work for another PR:
What is the motivation and context behind this change?
Pull request checklist: