Loading play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraBoundsWithSizeUpdate.kt +21 −7 Original line number Diff line number Diff line Loading @@ -29,15 +29,29 @@ internal class CameraBoundsWithSizeUpdate(val bounds: LatLngBounds, val width: I override fun getCameraPosition(map: MapboxMap): CameraPosition? { val padding = this.padding.clone() padding[0] += map.padding[0] + ((map.width - width) / 2).toInt() padding[1] += map.padding[1] + ((map.height - height) / 2).toInt() padding[2] += map.padding[2] + ((map.width - width) / 2).toInt() padding[3] += map.padding[3] + ((map.height - height) / 2).toInt() val mapPadding = map.cameraPosition.padding mapPadding?.let { for (i in 0..3) { padding[i] += it[i].toInt() } } val widthPadding = ((map.width - width) / 2).toInt() val heightPadding = ((map.height - height) / 2).toInt() padding[0] += widthPadding padding[1] += heightPadding padding[2] += widthPadding padding[3] += heightPadding Log.d(TAG, "map ${map.width} ${map.height}, set $width $height -> ${Arrays.toString(padding)}") return map.getCameraForLatLngBounds(bounds, padding)?.let { CameraPosition.Builder(it).padding( map.padding[0].toDouble(), map.padding[1].toDouble(), map.padding[2].toDouble(), map.padding[3].toDouble() ).build() CameraPosition.Builder(it) .apply { mapPadding?.let { padding(it) } }.build() } } Loading play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +4 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.mapbox.mapboxsdk.plugins.annotation.Annotation import com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_ROUND import com.google.android.gms.dynamic.unwrap import com.mapbox.mapboxsdk.WellKnownTileServer import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import org.microg.gms.maps.MapsConstants.* import org.microg.gms.maps.mapbox.model.* import org.microg.gms.maps.mapbox.utils.MapContext Loading Loading @@ -488,7 +489,9 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) { Log.d(TAG, "setPadding: $left $top $right $bottom") map?.let { map -> map.setPadding(left, top, right, bottom) CameraUpdateFactory.paddingTo(left.toDouble(), top.toDouble(), right.toDouble(), bottom.toDouble()) .let { map.moveCamera(it) } val fourDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_four_dp)?.toInt() ?: 0 val ninetyTwoDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_ninety_two_dp)?.toInt() Loading Loading
play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/CameraBoundsWithSizeUpdate.kt +21 −7 Original line number Diff line number Diff line Loading @@ -29,15 +29,29 @@ internal class CameraBoundsWithSizeUpdate(val bounds: LatLngBounds, val width: I override fun getCameraPosition(map: MapboxMap): CameraPosition? { val padding = this.padding.clone() padding[0] += map.padding[0] + ((map.width - width) / 2).toInt() padding[1] += map.padding[1] + ((map.height - height) / 2).toInt() padding[2] += map.padding[2] + ((map.width - width) / 2).toInt() padding[3] += map.padding[3] + ((map.height - height) / 2).toInt() val mapPadding = map.cameraPosition.padding mapPadding?.let { for (i in 0..3) { padding[i] += it[i].toInt() } } val widthPadding = ((map.width - width) / 2).toInt() val heightPadding = ((map.height - height) / 2).toInt() padding[0] += widthPadding padding[1] += heightPadding padding[2] += widthPadding padding[3] += heightPadding Log.d(TAG, "map ${map.width} ${map.height}, set $width $height -> ${Arrays.toString(padding)}") return map.getCameraForLatLngBounds(bounds, padding)?.let { CameraPosition.Builder(it).padding( map.padding[0].toDouble(), map.padding[1].toDouble(), map.padding[2].toDouble(), map.padding[3].toDouble() ).build() CameraPosition.Builder(it) .apply { mapPadding?.let { padding(it) } }.build() } } Loading
play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +4 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.mapbox.mapboxsdk.plugins.annotation.Annotation import com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_ROUND import com.google.android.gms.dynamic.unwrap import com.mapbox.mapboxsdk.WellKnownTileServer import com.mapbox.mapboxsdk.camera.CameraUpdateFactory import org.microg.gms.maps.MapsConstants.* import org.microg.gms.maps.mapbox.model.* import org.microg.gms.maps.mapbox.utils.MapContext Loading Loading @@ -488,7 +489,9 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) override fun setPadding(left: Int, top: Int, right: Int, bottom: Int) { Log.d(TAG, "setPadding: $left $top $right $bottom") map?.let { map -> map.setPadding(left, top, right, bottom) CameraUpdateFactory.paddingTo(left.toDouble(), top.toDouble(), right.toDouble(), bottom.toDouble()) .let { map.moveCamera(it) } val fourDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_four_dp)?.toInt() ?: 0 val ninetyTwoDp = mapView?.context?.resources?.getDimension(R.dimen.mapbox_ninety_two_dp)?.toInt() Loading