add option to show Google Maps traffic layer (fixes #19)

This commit is contained in:
Johan von Forstner
2020-05-24 11:26:13 +02:00
parent 1f81a11ad1
commit 34fe126fd0
6 changed files with 45 additions and 2 deletions

View File

@@ -331,6 +331,9 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
vm.mapType.observe(viewLifecycleOwner, Observer {
map?.mapType = it
})
vm.mapTrafficEnabled.observe(viewLifecycleOwner, Observer {
map?.isTrafficEnabled = it
})
}
private fun updateBackPressedCallback() {
@@ -443,7 +446,9 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
override fun onMapReady(map: GoogleMap) {
this.map = map
map.uiSettings.isTiltGesturesEnabled = false;
map.uiSettings.isTiltGesturesEnabled = false
map.isIndoorEnabled = false
map.uiSettings.isIndoorLevelPickerEnabled = false
map.setOnCameraIdleListener {
vm.mapPosition.value = MapPosition(
map.projection.visibleRegion.latLngBounds, map.cameraPosition.zoom

View File

@@ -144,6 +144,12 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
}
}
val mapTrafficEnabled: MutableLiveData<Boolean> by lazy {
MutableLiveData<Boolean>().apply {
value = false
}
}
fun setMapType(type: Int) {
mapType.value = type
}