-
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
22 changed files
with
1,562 additions
and
341 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.
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
package com.mapbox.maps.testapp.auto.car | ||
|
||
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.addLayer | ||
import com.mapbox.maps.extension.style.layers.generated.SkyLayer | ||
import com.mapbox.maps.extension.style.layers.getLayerAs | ||
import com.mapbox.maps.extension.style.sources.addSource | ||
import com.mapbox.maps.extension.style.sources.generated.RasterDemSource | ||
import com.mapbox.maps.extension.style.sources.getSourceAs | ||
import com.mapbox.maps.extension.style.terrain.generated.setTerrain | ||
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. | ||
*/ | ||
class CarMapShowcase : MapboxCarMapObserver { | ||
|
||
override fun loaded(mapboxCarMapSurface: MapboxCarMapSurface) { | ||
with(mapboxCarMapSurface.style) { | ||
updateSkyLayer(mapboxCarMapSurface.carContext.isDarkMode) | ||
updateTerrainLayer() | ||
} | ||
} | ||
|
||
private fun Style.updateSkyLayer(isDarkMode: Boolean) { | ||
var skyLayer = getLayerAs<SkyLayer>(SKY_LAYER) | ||
if (skyLayer == null) { | ||
skyLayer = SkyLayer(SKY_LAYER) | ||
addLayer(skyLayer) | ||
} | ||
// 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. | ||
if (isDarkMode) { | ||
skyLayer.skyAtmosphereSun(listOf(-50.0, 90.2)) | ||
} else { | ||
skyLayer.skyAtmosphereSun(listOf(0.0, 0.0)) | ||
} | ||
} | ||
|
||
private fun Style.updateTerrainLayer() { | ||
var demSource = getSourceAs<RasterDemSource>(DEM_SOURCE) | ||
if (demSource == null) { | ||
demSource = RasterDemSource.Builder(DEM_SOURCE) | ||
.url(TERRAIN_URL_TILE_RESOURCE) | ||
.tileSize(514) | ||
.build() | ||
addSource(demSource) | ||
} | ||
setTerrain(terrain(DEM_SOURCE) { exaggeration(1.7) }) | ||
} | ||
|
||
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" | ||
} | ||
} |
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
Oops, something went wrong.