Loading play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/LiteGoogleMap.kt +18 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 }) { Loading Loading @@ -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) Loading @@ -363,7 +366,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr this.currentSnapshotter = null } } }, null) } fun getMapAsync(callback: IOnMapReadyCallback) { Loading Loading @@ -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 } Loading Loading @@ -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" } Loading
play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/LiteGoogleMap.kt +18 −4 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 }) { Loading Loading @@ -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) Loading @@ -363,7 +366,7 @@ class LiteGoogleMapImpl(context: Context, var options: GoogleMapOptions) : Abstr this.currentSnapshotter = null } } }, null) } fun getMapAsync(callback: IOnMapReadyCallback) { Loading Loading @@ -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 } Loading Loading @@ -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" }