diff --git a/CHANGELOG.md b/CHANGELOG.md index bd00b805..b697edb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ CameraOptions( ))) ``` +* Bump Pigeon to 17.1.2 +* [iOS] Fix crash in `onStyleImageMissingListener`. +* Fix camera center not applied from map init options. + ### 1.0.0 * Add `MapboxMapsOptions.get/setWorldview()` and ``MapboxMapsOptions.get/setLanguage()`. Use this to to adjust administrative boundaries/map language based on the map's audience. diff --git a/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapFactory.kt b/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapFactory.kt index bc5de4d7..c90c9b26 100644 --- a/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapFactory.kt +++ b/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapFactory.kt @@ -1,13 +1,25 @@ package com.mapbox.maps.mapbox_maps import android.content.Context -import com.mapbox.common.* -import com.mapbox.maps.* +import com.mapbox.maps.CameraOptions +import com.mapbox.maps.ConstrainMode +import com.mapbox.maps.ContextMode +import com.mapbox.maps.EdgeInsets +import com.mapbox.maps.GlyphsRasterizationMode +import com.mapbox.maps.GlyphsRasterizationOptions +import com.mapbox.maps.MapInitOptions +import com.mapbox.maps.MapOptions +import com.mapbox.maps.NorthOrientation +import com.mapbox.maps.ScreenCoordinate +import com.mapbox.maps.Size +import com.mapbox.maps.Style +import com.mapbox.maps.ViewportMode +import com.mapbox.maps.applyDefaultParams +import com.mapbox.maps.mapbox_maps.mapping.turf.PointDecoder import io.flutter.plugin.common.BinaryMessenger import io.flutter.plugin.common.StandardMessageCodec import io.flutter.plugin.platform.PlatformView import io.flutter.plugin.platform.PlatformViewFactory -import java.lang.RuntimeException class MapboxMapFactory( private val messenger: BinaryMessenger, @@ -71,8 +83,8 @@ class MapboxMapFactory( cameraOptions[4]?.let { cameraOptionsBuilder.bearing(it as Double) } - (cameraOptions[0] as? Map?)?.let { - cameraOptionsBuilder.center(it.toPoint()) + (cameraOptions[0] as? List?)?.let { + cameraOptionsBuilder.center(PointDecoder.fromList(it)) } cameraOptions[5]?.let { cameraOptionsBuilder.pitch(it as Double) diff --git a/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/mapping/turf/TurfAdapters.kt b/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/mapping/turf/TurfAdapters.kt index 73d3af68..27d0e999 100644 --- a/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/mapping/turf/TurfAdapters.kt +++ b/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/mapping/turf/TurfAdapters.kt @@ -1,6 +1,5 @@ package com.mapbox.maps.mapbox_maps.mapping.turf -import com.google.gson.Gson import com.mapbox.geojson.Point fun Point.toList(): List { @@ -8,7 +7,11 @@ fun Point.toList(): List { } object PointDecoder { + @Suppress("UNCHECKED_CAST") fun fromList(list: List): Point { - return Point.fromJson(Gson().toJson(list.first())) + val rawPoint = list.first() as Map + val coordinates = rawPoint["coordinates"] as List + + return Point.fromLngLat(coordinates[0], coordinates[1]) } } \ No newline at end of file diff --git a/ios/Classes/MapboxMapFactory.swift b/ios/Classes/MapboxMapFactory.swift index c3a8eeaa..9c2beac1 100644 --- a/ios/Classes/MapboxMapFactory.swift +++ b/ios/Classes/MapboxMapFactory.swift @@ -84,8 +84,8 @@ class MapboxMapFactory: NSObject, FlutterPlatformViewFactory { let bearing: CLLocationDirection? = cameraOptionsMap[4] as? CLLocationDirection let pitch: CGFloat? = cameraOptionsMap[5] as? CGFloat - if let centerMap = cameraOptionsMap[0] as? [String: Any] { - center = convertDictionaryToCLLocationCoordinate2D(dict: centerMap) + if let centerList = cameraOptionsMap[0] as? [Any] { + center = Point.fromList(centerList).coordinates } if let paddingMap = cameraOptionsMap[1] as? [CGFloat] {