Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0150ff2e authored by Fynn Godau's avatar Fynn Godau
Browse files

Fix builds after merge

Custom colors not yet enabled for lite mode maps due to problems
parent d86a8b5a
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.mapbox.mapboxsdk.style.layers.*
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.turf.TurfConstants.UNIT_METERS
import com.mapbox.turf.TurfMeasurement
import org.microg.gms.maps.MapsConstants
import org.microg.gms.maps.mapbox.model.*
import org.microg.gms.maps.mapbox.utils.toGms
import org.microg.gms.maps.mapbox.utils.toMapbox
@@ -77,6 +78,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr
    private var cameraBounds: com.mapbox.mapboxsdk.geometry.LatLngBounds? = null

    private var mapType: Int = options.mapType
    private var mapStyle: MapStyleOptions? = null

    private var currentSnapshotter: MapSnapshotter? = null

@@ -89,7 +91,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr

    private var myLocationEnabled = false
    private var myLocation: Location? = null
    private var locationEngineProvider: LocationEngine = LocationEngineProvider.getBestLocationEngine(mapContext)
    private var locationEngineProvider: LocationEngine = LocationEngineDefault.getDefaultLocationEngine(mapContext)
    private val locationListener = object : LocationEngineCallback<LocationEngineResult> {
        override fun onSuccess(result: LocationEngineResult?) {
            this@LiteGoogleMapImpl.myLocation = result?.lastLocation
@@ -249,6 +251,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr
        val pixelHeight = map.height

        val styleBuilder = Style.Builder().fromUri(getStyleUriByMapType(mapType))
        // TODO should be getStyle(mapContext, mapType, mapStyle)

        // Add visible polygons (before polylines, so that they are drawn below their strokes)
        for (polygon in polygons.filter { it.isVisible }) {
@@ -340,7 +343,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr
            this.currentSnapshotter = snapshotter
        }

        snapshotter.start {
        snapshotter.start({

            val cameraPositionChanged = cameraPosition != lastSnapshot?.cameraPosition || (cameraBounds != lastSnapshot?.cameraBounds)

@@ -363,7 +366,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr
                this.currentSnapshotter = null
            }

        }
        }, null)
    }

    fun getMapAsync(callback: IOnMapReadyCallback) {
@@ -612,6 +615,8 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr

    override fun setMapStyle(options: MapStyleOptions?): Boolean {
        Log.d(TAG, "setMapStyle options: " + options?.getJson())
        mapStyle = options

        return true
    }

@@ -660,3 +665,12 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr
        private val BUNDLE_CAMERA_BOUNDS = "cameraBounds"
    }
}

// TODO custom colors
fun getStyleUriByMapType(mapType: Int) = when (mapType) {
    MapsConstants.MAP_TYPE_SATELLITE -> "mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"
    MapsConstants.MAP_TYPE_TERRAIN -> "mapbox://styles/mapbox/outdoors-v12"
    MapsConstants.MAP_TYPE_HYBRID -> "mapbox://styles/microg/cjxgloted25ap1ct4uex7m6hi"
    //MAP_TYPE_NONE, MAP_TYPE_NORMAL,
    else -> "mapbox://styles/microg/cjui4020201oo1fmca7yuwbor"
}