Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 2.17.0-rc.1

* [iOS] Fix annotation interaction handlers (tap, drag etc.) not working after annotation update.
* Add the ability to get all annotations from an annotation manager.
* Add `customData` field to annotations to be able to pass user data.

### 2.17.0-beta.1

> [!NOTE]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is generated.
package com.mapbox.maps.mapbox_maps.annotation

import com.google.gson.Gson
import com.mapbox.maps.mapbox_maps.pigeons.*
import com.mapbox.maps.plugin.annotation.generated.CircleAnnotationManager
import toCircleElevationReference
Expand All @@ -16,6 +17,14 @@ class CircleAnnotationController(private val delegate: ControllerDelegate) : _Ci
private val annotationMap = mutableMapOf<String, com.mapbox.maps.plugin.annotation.generated.CircleAnnotation>()
private val managerCreateAnnotationMap = mutableMapOf<String, MutableList<String>>()

override fun getAnnotations(
managerId: String,
callback: (Result<List<CircleAnnotation>>) -> Unit
) {
val manager = delegate.getManager(managerId) as CircleAnnotationManager
callback(Result.success(manager.annotations.map { it.toFLTCircleAnnotation() }))
}

override fun create(
managerId: String,
annotationOption: CircleAnnotationOptions,
Expand Down Expand Up @@ -490,6 +499,7 @@ fun com.mapbox.maps.plugin.annotation.generated.CircleAnnotation.toFLTCircleAnno
circleStrokeColor = circleStrokeColorInt?.toUInt()?.toLong(),
circleStrokeOpacity = circleStrokeOpacity,
circleStrokeWidth = circleStrokeWidth,
customData = if (getData() != null) Gson().fromJson<Map<String, Any>>(getData()!!, Map::class.java) else null
)
}

Expand Down Expand Up @@ -525,6 +535,9 @@ fun CircleAnnotationOptions.toCircleAnnotationOptions(): com.mapbox.maps.plugin.
this.circleStrokeWidth?.let {
options.withCircleStrokeWidth(it)
}
this.customData?.let {
options.withData(Gson().toJsonTree(it))
}
return options
}
// End of generated file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.mapbox.maps.mapbox_maps.annotation

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import com.google.gson.Gson
import com.mapbox.maps.mapbox_maps.pigeons.*
import com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import toFLTIconAnchor
Expand Down Expand Up @@ -39,6 +40,14 @@ class PointAnnotationController(private val delegate: ControllerDelegate) : _Poi
private val annotationMap = mutableMapOf<String, com.mapbox.maps.plugin.annotation.generated.PointAnnotation>()
private val managerCreateAnnotationMap = mutableMapOf<String, MutableList<String>>()

override fun getAnnotations(
managerId: String,
callback: (Result<List<PointAnnotation>>) -> Unit
) {
val manager = delegate.getManager(managerId) as PointAnnotationManager
callback(Result.success(manager.annotations.map { it.toFLTPointAnnotation() }))
}

override fun create(
managerId: String,
annotationOption: PointAnnotationOptions,
Expand Down Expand Up @@ -1781,6 +1790,7 @@ fun com.mapbox.maps.plugin.annotation.generated.PointAnnotation.toFLTPointAnnota
textHaloWidth = textHaloWidth,
textOcclusionOpacity = textOcclusionOpacity,
textOpacity = textOpacity,
customData = if (getData() != null) Gson().fromJson<Map<String, Any>>(getData()!!, Map::class.java) else null
)
}

Expand Down Expand Up @@ -1900,6 +1910,9 @@ fun PointAnnotationOptions.toPointAnnotationOptions(): com.mapbox.maps.plugin.an
this.textOpacity?.let {
options.withTextOpacity(it)
}
this.customData?.let {
options.withData(Gson().toJsonTree(it))
}
return options
}
// End of generated file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is generated.
package com.mapbox.maps.mapbox_maps.annotation

import com.google.gson.Gson
import com.mapbox.maps.mapbox_maps.pigeons.*
import com.mapbox.maps.plugin.annotation.generated.PolygonAnnotationManager
import toFLTFillElevationReference
Expand All @@ -12,6 +13,14 @@ class PolygonAnnotationController(private val delegate: ControllerDelegate) : _P
private val annotationMap = mutableMapOf<String, com.mapbox.maps.plugin.annotation.generated.PolygonAnnotation>()
private val managerCreateAnnotationMap = mutableMapOf<String, MutableList<String>>()

override fun getAnnotations(
managerId: String,
callback: (Result<List<PolygonAnnotation>>) -> Unit
) {
val manager = delegate.getManager(managerId) as PolygonAnnotationManager
callback(Result.success(manager.annotations.map { it.toFLTPolygonAnnotation() }))
}

override fun create(
managerId: String,
annotationOption: PolygonAnnotationOptions,
Expand Down Expand Up @@ -492,6 +501,7 @@ fun com.mapbox.maps.plugin.annotation.generated.PolygonAnnotation.toFLTPolygonAn
// colorInt is 32 bit and may be bigger than MAX_INT, so transfer to UInt firstly and then to Long.
fillTunnelStructureColor = fillTunnelStructureColorInt?.toUInt()?.toLong(),
fillZOffset = fillZOffset,
customData = if (getData() != null) Gson().fromJson<Map<String, Any>>(getData()!!, Map::class.java) else null
)
}

Expand Down Expand Up @@ -530,6 +540,9 @@ fun PolygonAnnotationOptions.toPolygonAnnotationOptions(): com.mapbox.maps.plugi
this.fillZOffset?.let {
options.withFillZOffset(it)
}
this.customData?.let {
options.withData(Gson().toJsonTree(it))
}
return options
}
// End of generated file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file is generated.
package com.mapbox.maps.mapbox_maps.annotation

import com.google.gson.Gson
import com.mapbox.maps.extension.style.utils.ColorUtils
import com.mapbox.maps.mapbox_maps.pigeons.*
import com.mapbox.maps.plugin.annotation.generated.PolylineAnnotationManager
Expand All @@ -19,6 +20,14 @@ class PolylineAnnotationController(private val delegate: ControllerDelegate) : _
private val annotationMap = mutableMapOf<String, com.mapbox.maps.plugin.annotation.generated.PolylineAnnotation>()
private val managerCreateAnnotationMap = mutableMapOf<String, MutableList<String>>()

override fun getAnnotations(
managerId: String,
callback: (Result<List<PolylineAnnotation>>) -> Unit
) {
val manager = delegate.getManager(managerId) as PolylineAnnotationManager
callback(Result.success(manager.annotations.map { it.toFLTPolylineAnnotation() }))
}

override fun create(
managerId: String,
annotationOption: PolylineAnnotationOptions,
Expand Down Expand Up @@ -877,6 +886,7 @@ fun com.mapbox.maps.plugin.annotation.generated.PolylineAnnotation.toFLTPolyline
lineOpacity = lineOpacity,
linePattern = linePattern,
lineWidth = lineWidth,
customData = if (getData() != null) Gson().fromJson<Map<String, Any>>(getData()!!, Map::class.java) else null
)
}

Expand Down Expand Up @@ -924,6 +934,9 @@ fun PolylineAnnotationOptions.toPolylineAnnotationOptions(): com.mapbox.maps.plu
this.lineWidth?.let {
options.withLineWidth(it)
}
this.customData?.let {
options.withData(Gson().toJsonTree(it))
}
return options
}
// End of generated file.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ private fun wrapError(exception: Throwable): List<Any?> {
)
}
}
private fun deepEqualsCircleAnnotationMessenger(a: Any?, b: Any?): Boolean {
if (a is ByteArray && b is ByteArray) {
return a.contentEquals(b)
}
if (a is IntArray && b is IntArray) {
return a.contentEquals(b)
}
if (a is LongArray && b is LongArray) {
return a.contentEquals(b)
}
if (a is DoubleArray && b is DoubleArray) {
return a.contentEquals(b)
}
if (a is Array<*> && b is Array<*>) {
return a.size == b.size &&
a.indices.all { deepEqualsCircleAnnotationMessenger(a[it], b[it]) }
}
if (a is Map<*, *> && b is Map<*, *>) {
return a.size == b.size && a.keys.all {
(b as Map<Any?, Any?>).containsKey(it) &&
deepEqualsCircleAnnotationMessenger(a[it], b[it])
}
}
return a == b
}

/**
* Selects the base of circle-elevation. Some modes might require precomputed elevation data in the tileset.
Expand Down Expand Up @@ -146,7 +171,9 @@ data class CircleAnnotation(
*/
val circleStrokeWidth: Double? = null,
/** Property to determine whether annotation can be manually moved around map. */
val isDraggable: Boolean? = null
val isDraggable: Boolean? = null,
/** JSON convertible properties associated with the annotation, used to enrich Feature GeoJSON `properties["custom_data"]` field. */
val customData: Map<String, Any>? = null
) {
companion object {
fun fromList(pigeonVar_list: List<Any?>): CircleAnnotation {
Expand All @@ -161,7 +188,8 @@ data class CircleAnnotation(
val circleStrokeOpacity = pigeonVar_list[8] as Double?
val circleStrokeWidth = pigeonVar_list[9] as Double?
val isDraggable = pigeonVar_list[10] as Boolean?
return CircleAnnotation(id, geometry, circleSortKey, circleBlur, circleColor, circleOpacity, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, isDraggable)
val customData = pigeonVar_list[11] as Map<String, Any>?
return CircleAnnotation(id, geometry, circleSortKey, circleBlur, circleColor, circleOpacity, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, isDraggable, customData)
}
}
fun toList(): List<Any?> {
Expand All @@ -177,6 +205,7 @@ data class CircleAnnotation(
circleStrokeOpacity,
circleStrokeWidth,
isDraggable,
customData,
)
}
override fun equals(other: Any?): Boolean {
Expand All @@ -196,7 +225,8 @@ data class CircleAnnotation(
circleStrokeColor == other.circleStrokeColor &&
circleStrokeOpacity == other.circleStrokeOpacity &&
circleStrokeWidth == other.circleStrokeWidth &&
isDraggable == other.isDraggable
isDraggable == other.isDraggable &&
deepEqualsCircleAnnotationMessenger(customData, other.customData)
}

override fun hashCode(): Int = toList().hashCode()
Expand Down Expand Up @@ -244,7 +274,9 @@ data class CircleAnnotationOptions(
*/
val circleStrokeWidth: Double? = null,
/** Property to determine whether annotation can be manually moved around map. */
val isDraggable: Boolean? = null
val isDraggable: Boolean? = null,
/** JSON convertible properties associated with the annotation, used to enrich Feature GeoJSON `properties["custom_data"]` field. */
val customData: Map<String, Any>? = null
) {
companion object {
fun fromList(pigeonVar_list: List<Any?>): CircleAnnotationOptions {
Expand All @@ -258,7 +290,8 @@ data class CircleAnnotationOptions(
val circleStrokeOpacity = pigeonVar_list[7] as Double?
val circleStrokeWidth = pigeonVar_list[8] as Double?
val isDraggable = pigeonVar_list[9] as Boolean?
return CircleAnnotationOptions(geometry, circleSortKey, circleBlur, circleColor, circleOpacity, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, isDraggable)
val customData = pigeonVar_list[10] as Map<String, Any>?
return CircleAnnotationOptions(geometry, circleSortKey, circleBlur, circleColor, circleOpacity, circleRadius, circleStrokeColor, circleStrokeOpacity, circleStrokeWidth, isDraggable, customData)
}
}
fun toList(): List<Any?> {
Expand All @@ -273,6 +306,7 @@ data class CircleAnnotationOptions(
circleStrokeOpacity,
circleStrokeWidth,
isDraggable,
customData,
)
}
override fun equals(other: Any?): Boolean {
Expand All @@ -291,7 +325,8 @@ data class CircleAnnotationOptions(
circleStrokeColor == other.circleStrokeColor &&
circleStrokeOpacity == other.circleStrokeOpacity &&
circleStrokeWidth == other.circleStrokeWidth &&
isDraggable == other.isDraggable
isDraggable == other.isDraggable &&
deepEqualsCircleAnnotationMessenger(customData, other.customData)
}

override fun hashCode(): Int = toList().hashCode()
Expand Down Expand Up @@ -374,6 +409,7 @@ private open class CircleAnnotationMessengerPigeonCodec : StandardMessageCodec()

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
interface _CircleAnnotationMessenger {
fun getAnnotations(managerId: String, callback: (Result<List<CircleAnnotation>>) -> Unit)
fun create(managerId: String, annotationOption: CircleAnnotationOptions, callback: (Result<CircleAnnotation>) -> Unit)
fun createMulti(managerId: String, annotationOptions: List<CircleAnnotationOptions>, callback: (Result<List<CircleAnnotation>>) -> Unit)
fun update(managerId: String, annotation: CircleAnnotation, callback: (Result<Unit>) -> Unit)
Expand Down Expand Up @@ -417,6 +453,26 @@ interface _CircleAnnotationMessenger {
@JvmOverloads
fun setUp(binaryMessenger: BinaryMessenger, api: _CircleAnnotationMessenger?, messageChannelSuffix: String = "") {
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.mapbox_maps_flutter._CircleAnnotationMessenger.getAnnotations$separatedMessageChannelSuffix", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val managerIdArg = args[0] as String
api.getAnnotations(managerIdArg) { result: Result<List<CircleAnnotation>> ->
val error = result.exceptionOrNull()
if (error != null) {
reply.reply(wrapError(error))
} else {
val data = result.getOrNull()
reply.reply(wrapResult(data))
}
}
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.mapbox_maps_flutter._CircleAnnotationMessenger.create$separatedMessageChannelSuffix", codec)
if (api != null) {
Expand Down
Loading