Skip to content

Commit

Permalink
Maps: Fix handling of bounds crossing antimeridian
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-v-in committed Jul 17, 2023
1 parent a3e0f17 commit 28ca324
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.microg.gms.maps.mapbox.utils

import android.os.Bundle
import android.util.Log
import com.google.android.gms.maps.internal.ICancelableCallback
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.geometry.VisibleRegion
import com.mapbox.mapboxsdk.maps.MapboxMap
import org.microg.gms.maps.mapbox.TAG
import com.google.android.gms.maps.model.CameraPosition as GmsCameraPosition
import com.google.android.gms.maps.model.LatLng as GmsLatLng
import com.google.android.gms.maps.model.LatLngBounds as GmsLatLngBounds
Expand All @@ -35,7 +37,7 @@ fun GmsLatLng.toMapbox(): LatLng =
fun GmsLatLng.toPoint() = Point.fromLngLat(latitude, longitude)

fun GmsLatLngBounds.toMapbox(): LatLngBounds =
LatLngBounds.from(this.northeast.latitude, this.northeast.longitude, this.southwest.latitude, this.southwest.longitude)
LatLngBounds.from(this.northeast.latitude, this.northeast.longitude + if (this.northeast.longitude < this.southwest.longitude) 360.0 else 0.0, this.southwest.latitude, this.southwest.longitude)

fun GmsCameraPosition.toMapbox(): CameraPosition =
CameraPosition.Builder()
Expand Down

0 comments on commit 28ca324

Please sign in to comment.