-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,940 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
android-auto-app/src/main/java/com/mapbox/maps/testapp/auto/car/CarJavaInterfaceChecker.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
android-auto-app/src/main/java/com/mapbox/maps/testapp/auto/car/CarMapShowcase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.mapbox.maps.testapp.auto.car | ||
|
||
import androidx.car.app.CarContext | ||
import com.mapbox.maps.MapboxExperimental | ||
import com.mapbox.maps.Style | ||
import com.mapbox.maps.extension.androidauto.MapboxCarMapObserver | ||
import com.mapbox.maps.extension.androidauto.MapboxCarMapSurface | ||
import com.mapbox.maps.extension.style.layers.generated.skyLayer | ||
import com.mapbox.maps.extension.style.layers.properties.generated.SkyType | ||
import com.mapbox.maps.extension.style.sources.generated.rasterDemSource | ||
import com.mapbox.maps.extension.style.style | ||
import com.mapbox.maps.extension.style.terrain.generated.terrain | ||
|
||
/** | ||
* Example showing how you can add a sky layer that has a sun direction, | ||
* and adding a terrain layer to show mountains. | ||
*/ | ||
@OptIn(MapboxExperimental::class) | ||
class CarMapShowcase : MapboxCarMapObserver { | ||
|
||
private var mapboxCarMapSurface: MapboxCarMapSurface? = null | ||
|
||
override fun onAttached(mapboxCarMapSurface: MapboxCarMapSurface) { | ||
this.mapboxCarMapSurface = mapboxCarMapSurface | ||
loadMapStyle(mapboxCarMapSurface.carContext) | ||
} | ||
|
||
override fun onDetached(mapboxCarMapSurface: MapboxCarMapSurface) { | ||
this.mapboxCarMapSurface = null | ||
} | ||
|
||
fun mapStyleUri(carContext: CarContext): String { | ||
return if (carContext.isDarkMode) Style.TRAFFIC_NIGHT else Style.TRAFFIC_DAY | ||
} | ||
|
||
fun loadMapStyle(carContext: CarContext) { | ||
// https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#paint-sky-sky-atmosphere-sun | ||
// Position of the sun center [a azimuthal angle, p polar angle]. | ||
// Azimuthal is degrees from north, where 0.0 is north. | ||
// Polar is degrees from overhead, where 0.0 is overhead. | ||
val sunDirection = if (carContext.isDarkMode) listOf(-50.0, 90.2) else listOf(0.0, 0.0) | ||
|
||
mapboxCarMapSurface?.mapSurface?.getMapboxMap()?.loadStyle( | ||
styleExtension = style(mapStyleUri(carContext)) { | ||
+rasterDemSource(DEM_SOURCE) { | ||
url(TERRAIN_URL_TILE_RESOURCE) | ||
tileSize(514) | ||
} | ||
+terrain(DEM_SOURCE) | ||
+skyLayer(SKY_LAYER) { | ||
skyType(SkyType.ATMOSPHERE) | ||
skyAtmosphereSun(sunDirection) | ||
} | ||
} | ||
) | ||
} | ||
|
||
companion object { | ||
private const val SKY_LAYER = "sky" | ||
private const val DEM_SOURCE = "mapbox-dem" | ||
private const val TERRAIN_URL_TILE_RESOURCE = "mapbox://mapbox.mapbox-terrain-dem-v1" | ||
} | ||
} |
Oops, something went wrong.