Skip to content

Commit

Permalink
Expose radius parameter for interactions (#2867)
Browse files Browse the repository at this point in the history
* Expose radius parameter for interactions

* License, docs
  • Loading branch information
kiryldz authored Nov 25, 2024
1 parent e59cdde commit 2f0e074
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 83 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Mapbox welcomes participation and contributions from everyone.
* Adds support for `fillZOffset` in `PolygonAnnotation`, `PolygonAnnotationManager`, `PolygonAnnotationOptions`.
* Introduce `BackgroundLayer.backgroundPitchAlignment` API to configure the orientation of background layer.
* Introduce `LocationIndicatorLayer.emphasisCircleGlowRange` and `LocationIndicatorLayer.emphasisCircleGlowRangeTransition` APIs to control the glow effect of the emphasis circle from the solid start to the fully transparent end and to set the transition options for the `emphasisCircleGlowRange` property, respectively.

* Introduce `radius` parameter for `ClickInteraction` and `LongClickInteraction` to support an extra area around the interaction.
* [compose] Introduce `LocationIndicatorLayerState.emphasisCircleGlowRange` and `LocationIndicatorLayerState.emphasisCircleGlowRangeTransition` properties.
* [compose] Introduce `FillLayerState.fillZOffset` and `FillLayerState.fillZOffsetTransition` properties.
* [compose] Introduce `FillExtrusionLayerState.fillExtrusionBaseAlignment` and `FillExtrusionLayerState.fillExtrusionHeightAlignment` properties.
* [compose] Introduce `BackgroundLayerState.backgroundPitchAlignment` property.
* [compose] Adds support for `fillZOffset` in `PolygonAnnotationState`, `PolygonAnnotationGroupState`.
* [compose] Expose `MapViewportState.cameraForCoordinates` method.

* [compose] Introduce `radius` parameter for all relevant compose functions for interactions to support an extra area around the interaction.

# 11.7.3 November 19, 2024
## Bug fixes 🐞
Expand Down
10 changes: 9 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ License: [Mapbox Terms of Service](https://www.mapbox.com/legal/tos/)

===========================================================================

Mapbox Maps Android uses portions of the mapbox-base-annotation.

URL: [https://github.com/mapbox/mapbox-maps-android](https://github.com/mapbox/mapbox-maps-android)

License: [Mapbox Terms of Service](https://www.mapbox.com/legal/tos/)

===========================================================================

Mapbox Maps Android uses portions of the okhttp.

URL: [https://square.github.io/okhttp/](https://square.github.io/okhttp/)
Expand Down Expand Up @@ -474,7 +482,7 @@ License: [The Apache Software License, Version 2.0](http://www.apache.org/licens

===========================================================================

### MapboxCoreMaps,11.8.0,Mapbox ToS,Mapbox,https://www.mapbox.com/
### MapboxCoreMaps,11.9.0-beta.1,Mapbox ToS,Mapbox,https://www.mapbox.com/

```
Mapbox Core Maps version 11.0
Expand Down
36 changes: 18 additions & 18 deletions extension-compose/api/Release/metalava.txt

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions extension-compose/api/extension-compose.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,22 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
* @param id mandatory featureset id.
* @param importId optional style import id, if not set, the ID will be taken from [StyleImport.importId].
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when featureset is clicked.
*/
@MapboxExperimental
public fun onFeaturesetClicked(
id: String,
importId: String? = null,
filter: Expression? = null,
radius: Double? = null,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleImportInteractionsState = apply {
clickInteractionFeatureset(
featuresetId = id,
importId = importId,
filter = filter,
radius = radius,
onClick = onClick
)
}
Expand All @@ -74,19 +77,22 @@ public class StyleImportInteractionsState : BasicStyleInteractions() {
* @param id mandatory featureset id.
* @param importId optional style import id, if not set, the ID will be taken from [StyleImport.importId].
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when featureset is clicked.
*/
@MapboxExperimental
public fun onFeaturesetLongClicked(
id: String,
importId: String? = null,
filter: Expression? = null,
radius: Double? = null,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleImportInteractionsState = apply {
longClickInteractionFeatureset(
featuresetId = id,
importId = importId,
filter = filter,
radius = radius,
onLongClick = onLongClick
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,22 @@ public abstract class BasicStyleInteractions {
* @param featuresetId mandatory featureset id.
* @param importId optional style import id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when featureset is clicked.
*/
protected fun clickInteractionFeatureset(
featuresetId: String,
importId: String? = null,
filter: Expression? = null,
radius: Double?,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
) {
entries.add { import ->
ClickInteraction.featureset(
id = featuresetId,
importId = importId ?: import,
filter = filter,
radius = radius,
onClick = { feature, context ->
featuresetFeatureScope?.onClick(feature, context) ?: false
}
Expand All @@ -96,17 +99,20 @@ public abstract class BasicStyleInteractions {
*
* @param layerId mandatory layer id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when layer is clicked.
*/
protected fun clickInteractionLayer(
layerId: String,
filter: Expression? = null,
radius: Double?,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
) {
entries.add {
ClickInteraction.layer(
id = layerId,
filter = filter,
radius = radius,
onClick = { feature, context ->
featuresetFeatureScope?.onClick(feature, context) ?: false
}
Expand Down Expand Up @@ -152,19 +158,22 @@ public abstract class BasicStyleInteractions {
* @param featuresetId mandatory featureset id.
* @param importId optional style import id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when featureset is clicked.
*/
protected fun longClickInteractionFeatureset(
featuresetId: String,
importId: String? = null,
filter: Expression? = null,
radius: Double?,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
) {
entries.add { import ->
LongClickInteraction.featureset(
id = featuresetId,
importId = importId ?: import,
filter = filter,
radius = radius,
onLongClick = { feature, context ->
featuresetFeatureScope?.onLongClick(feature, context) ?: false
}
Expand All @@ -179,17 +188,20 @@ public abstract class BasicStyleInteractions {
*
* @param layerId mandatory layer id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when layer is clicked.
*/
protected fun longClickInteractionLayer(
layerId: String,
filter: Expression? = null,
radius: Double?,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
) {
entries.add {
LongClickInteraction.layer(
id = layerId,
filter = filter,
radius = radius,
onLongClick = { feature, context ->
featuresetFeatureScope?.onLongClick(feature, context) ?: false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@ public class StyleInteractionsState : BasicStyleInteractions() {
* @param id mandatory featureset id.
* @param importId optional style import id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when featureset is clicked.
*/
@MapboxExperimental
public fun onFeaturesetClicked(
id: String,
importId: String? = null,
filter: Expression? = null,
radius: Double? = null,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleInteractionsState = apply {
clickInteractionFeatureset(
featuresetId = id,
importId = importId,
filter = filter,
radius = radius,
onClick = onClick
)
}
Expand All @@ -72,15 +75,17 @@ public class StyleInteractionsState : BasicStyleInteractions() {
*
* @param id mandatory layer id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when layer is clicked.
*/
@MapboxExperimental
public fun onLayerClicked(
id: String,
filter: Expression? = null,
radius: Double? = null,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleInteractionsState = apply {
clickInteractionLayer(layerId = id, filter = filter, onClick = onClick)
clickInteractionLayer(layerId = id, filter = filter, radius = radius, onClick = onClick)
}

/**
Expand All @@ -91,19 +96,22 @@ public class StyleInteractionsState : BasicStyleInteractions() {
* @param id mandatory featureset id.
* @param importId optional style import id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when featureset is clicked.
*/
@MapboxExperimental
public fun onFeaturesetLongClicked(
id: String,
importId: String? = null,
filter: Expression? = null,
radius: Double? = null,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleInteractionsState = apply {
longClickInteractionFeatureset(
featuresetId = id,
importId = importId,
filter = filter,
radius = radius,
onLongClick = onLongClick
)
}
Expand All @@ -115,15 +123,17 @@ public class StyleInteractionsState : BasicStyleInteractions() {
*
* @param id mandatory layer id.
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when layer is clicked.
*/
@MapboxExperimental
public fun onLayerLongClicked(
id: String,
filter: Expression? = null,
radius: Double? = null,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): StyleInteractionsState = apply {
longClickInteractionLayer(layerId = id, filter = filter, onLongClick = onLongClick)
longClickInteractionLayer(layerId = id, filter = filter, radius = radius, onLongClick = onLongClick)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,20 @@ public class LayerInteractionsState : BasicStyleInteractions() {
* When several [ClickInteraction]s are registered for the same layer - the callbacks will be triggered from last to first.
*
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onClick callback triggered when layer is clicked.
*/
@MapboxExperimental
public fun onClicked(
filter: Expression? = null,
radius: Double? = null,
onClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): LayerInteractionsState = apply {
styleLayerEntries.add { layerId ->
ClickInteraction.layer(
id = layerId,
filter = filter,
radius = radius,
onClick = { feature, context ->
featuresetFeatureScope?.onClick(feature, context) ?: false
}
Expand All @@ -94,17 +97,20 @@ public class LayerInteractionsState : BasicStyleInteractions() {
* When several [LongClickInteraction]s are registered for the same layer - the callbacks will be triggered from last to first.
*
* @param filter optional filter. Defaults to NULL.
* @param radius of an extra area around touch in screen pixels. Defaults to NULL meaning 0-radius pixels area.
* @param onLongClick callback triggered when layer is clicked.
*/
@MapboxExperimental
public fun onLongClicked(
filter: Expression? = null,
radius: Double? = null,
onLongClick: FeaturesetFeatureScope.(FeaturesetFeature<FeatureState>, InteractionContext) -> Boolean
): LayerInteractionsState = apply {
styleLayerEntries.add { layerId ->
LongClickInteraction.layer(
id = layerId,
filter = filter,
radius = radius,
onLongClick = { feature, context ->
featuresetFeatureScope?.onLongClick(feature, context) ?: false
}
Expand Down
Loading

0 comments on commit 2f0e074

Please sign in to comment.