Skip to content

Commit

Permalink
introduce NavigationMapboxMap.Builder and expose vanishing point up…
Browse files Browse the repository at this point in the history
…date interval
  • Loading branch information
LukasPaczos committed Nov 6, 2020
1 parent 4613556 commit 3d3e86f
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ open class BasicNavigationActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS) {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, null, true, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.useSpecializedLocationLayer(true)
.vanishRouteLineEnabled(true)
.build()

mapInstanceState?.let { state ->
navigationMapboxMap?.restoreStateFrom(state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,13 @@ class BasicNavigationFragment :
isLocationComponentEnabled = true
}

navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true).apply {
addOnCameraTrackingChangedListener(cameraTrackingChangedListener)
addProgressChangeListener(mapboxNavigation)
setCamera(DynamicCamera(mapboxMap))
}
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build().apply {
addOnCameraTrackingChangedListener(cameraTrackingChangedListener)
addProgressChangeListener(mapboxNavigation)
setCamera(DynamicCamera(mapboxMap))
}

if (shouldSimulateRoute()) {
mapboxNavigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ import com.mapbox.navigation.ui.voice.NavigationSpeechPlayer
import com.mapbox.navigation.ui.voice.SpeechPlayerProvider
import com.mapbox.navigation.ui.voice.VoiceInstructionLoader
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.*
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.mapView
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.startNavigation
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import kotlinx.coroutines.channels.Channel
import okhttp3.Cache
import timber.log.Timber
Expand Down Expand Up @@ -199,7 +202,8 @@ class DebugMapboxNavigationKt :
style.addImage("raw", ContextCompat.getDrawable(this, R.drawable.ic_circle_red)!!)
style.addImage("enhanced", ContextCompat.getDrawable(this, R.drawable.ic_circle_blue)!!)

navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.build()
navigationMapboxMap.setCamera(DynamicCamera(mapboxMap))
navigationMapboxMap.addProgressChangeListener(mapboxNavigation)
navigationMapboxMap.setOnRouteSelectionChangeListener { route ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import com.mapbox.navigation.ui.camera.NavigationCamera
import com.mapbox.navigation.ui.map.NavigationMapboxMap
import kotlinx.android.synthetic.main.bottom_sheet_faster_route.*
import kotlinx.android.synthetic.main.content_faster_route_layout.*
import kotlinx.android.synthetic.main.content_faster_route_layout.mapView
import kotlinx.android.synthetic.main.content_faster_route_layout.startNavigation
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import timber.log.Timber
import java.lang.ref.WeakReference

Expand Down Expand Up @@ -205,7 +208,9 @@ class FasterRouteActivity : AppCompatActivity(), OnMapReadyCallback {

mapboxMap.setStyle(Style.MAPBOX_STREETS) {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()
navigationMapboxMap?.setOnRouteSelectionChangeListener { route ->
mapboxNavigation.setRoutes(
mapboxNavigation.getRoutes().toMutableList().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class FeedbackButtonActivity :

mapboxMap.setStyle(Style.MAPBOX_STREETS) {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()

mapboxNavigation?.registerRouteProgressObserver(ReplayProgressObserver(mapboxReplayer))
mapboxReplayer.pushRealLocation(this, 0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class FreeDriveNavigationActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()
mapInstanceState?.let { state ->
navigationMapboxMap?.restoreStateFrom(state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ class GuidanceViewActivity : AppCompatActivity(), OnMapReadyCallback {
.zoom(16.5)
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true).also {
it.addProgressChangeListener(mapboxNavigation)
}
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build().also {
it.addProgressChangeListener(mapboxNavigation)
}

// Ideally we should use Mapbox.getAccessToken(), but to show GuidanceView we need a
// specific access token for route request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ class InstructionViewActivity :
this.mapboxMap = mapboxMap
mapboxMap.setStyle(Style.MAPBOX_STREETS) {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()

when (directionRoute) {
null -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ class MapMatchingActivity : AppCompatActivity(), OnMapReadyCallback {
isLocationComponentEnabled = true
}
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true).apply {
setCamera(DynamicCamera(mapboxMap))
addProgressChangeListener(mapboxNavigation!!)
}
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build().apply {
setCamera(DynamicCamera(mapboxMap))
addProgressChangeListener(mapboxNavigation!!)
}
mapInstanceState?.let { state ->
navigationMapboxMap?.restoreStateFrom(state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ class ReRouteActivity :
override fun onMapReady(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()

mapboxNavigation?.navigationOptions?.locationEngine?.getLastLocation(
locationListenerCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import com.mapbox.navigation.examples.utils.Utils
import com.mapbox.navigation.examples.utils.extensions.toPoint
import com.mapbox.navigation.ui.camera.NavigationCamera
import com.mapbox.navigation.ui.map.NavigationMapboxMap
import kotlinx.android.synthetic.main.activity_basic_navigation_layout.*
import kotlinx.android.synthetic.main.activity_replay_route_layout.*
import kotlinx.android.synthetic.main.activity_replay_route_layout.container
import kotlinx.android.synthetic.main.activity_replay_route_layout.mapView
import kotlinx.android.synthetic.main.activity_replay_route_layout.startNavigation
import java.lang.ref.WeakReference

/**
Expand Down Expand Up @@ -78,7 +82,10 @@ class ReplayActivity : AppCompatActivity(), OnMapReadyCallback {
this.mapboxMap = mapboxMap
mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, null, true, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.useSpecializedLocationLayer(true)
.vanishRouteLineEnabled(true)
.build()
initializeFirstLocation()

mapboxNavigation?.attachFasterRouteObserver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import com.mapbox.navigation.examples.utils.extensions.toPoint
import com.mapbox.navigation.ui.camera.NavigationCamera
import com.mapbox.navigation.ui.map.NavigationMapboxMap
import kotlinx.android.synthetic.main.activity_replay_history_layout.*
import kotlinx.android.synthetic.main.activity_replay_history_layout.mapView
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -129,8 +131,13 @@ class ReplayHistoryActivity : AppCompatActivity() {
val (mapboxMap, style) = deferredMapboxWithStyle.await()
if (!isActive) return@launch

val navigationMapboxMap =
NavigationMapboxMap(mapView, mapboxMap, this@ReplayHistoryActivity, true)
val navigationMapboxMap = NavigationMapboxMap.Builder(
mapView,
mapboxMap,
this@ReplayHistoryActivity
)
.vanishRouteLineEnabled(true)
.build()
val navigationContext = ReplayNavigationContext(
locationEngine,
mapboxMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class ReplayWaypointsActivity : AppCompatActivity(), OnMapReadyCallback {
this.mapboxMap = mapboxMap
mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this, true)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()

// Center the map at current location. Using LocationEngineProvider because the
// replay engine won't have your last location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import com.mapbox.navigation.ui.internal.route.RouteConstants
import com.mapbox.navigation.ui.map.NavigationMapboxMap
import kotlinx.android.synthetic.main.activity_replay_route_layout.mapView
import kotlinx.android.synthetic.main.activity_route_alerts.distanceRemainingText
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import kotlin.math.absoluteValue
import kotlin.math.roundToInt

Expand Down Expand Up @@ -170,7 +171,7 @@ class RouteAlertsActivity : AppCompatActivity() {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(16.0))
mapboxMap.moveCamera(CameraUpdateFactory.tiltTo(45.0))
mapboxMap.setStyle(getString(R.string.mapbox_navigation_guidance_day)) { style ->
navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, this)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this).build()
mapboxNavigation.setRoutes(listOf(directionsRoute))
navigationMapboxMap?.apply {
updateLocationLayerRenderMode(RenderMode.GPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ import com.mapbox.navigation.ui.voice.SpeechPlayerProvider
import com.mapbox.navigation.ui.voice.VoiceInstructionLoader
import kotlinx.android.synthetic.main.bottom_sheet_faster_route.*
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.*
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.mapView
import kotlinx.android.synthetic.main.content_simple_mapbox_navigation.startNavigation
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import kotlinx.coroutines.channels.Channel
import okhttp3.Cache
import timber.log.Timber
Expand Down Expand Up @@ -193,12 +196,10 @@ class SimpleMapboxNavigationKt :
symbolManager = SymbolManager(mapView, mapboxMap, style)
style.addImage("marker", IconFactory.getInstance(this).defaultMarker().bitmap)

navigationMapboxMap = NavigationMapboxMap(
mapView,
mapboxMap,
this,
true
)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.useSpecializedLocationLayer(true)
.build()
navigationMapboxMap.setCamera(DynamicCamera(mapboxMap))
navigationMapboxMap.addProgressChangeListener(mapboxNavigation)
navigationMapboxMap.setOnRouteSelectionChangeListener { route ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ import com.mapbox.navigation.ui.camera.NavigationCamera
import com.mapbox.navigation.ui.map.NavigationMapboxMap
import com.mapbox.navigation.ui.summary.SummaryBottomSheet
import kotlinx.android.synthetic.main.activity_summary_bottom_sheet.*
import kotlinx.android.synthetic.main.activity_summary_bottom_sheet.mapView
import kotlinx.android.synthetic.main.activity_summary_bottom_sheet.recenterBtn
import kotlinx.android.synthetic.main.activity_summary_bottom_sheet.startNavigation
import kotlinx.android.synthetic.main.activity_summary_bottom_sheet.summaryBottomSheet
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import java.lang.ref.WeakReference

/**
Expand Down Expand Up @@ -141,12 +146,9 @@ class SummaryBottomSheetActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS) {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
navigationMapboxMap = NavigationMapboxMap(
mapView,
mapboxMap,
this,
true
)
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build()

when (directionRoute) {
null -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ import com.mapbox.navigation.ui.voice.NavigationSpeechPlayer
import com.mapbox.navigation.ui.voice.SpeechPlayerProvider
import com.mapbox.navigation.ui.voice.VoiceInstructionLoader
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.*
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.instructionView
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.mapView
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.recenterBtn
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.screenshotView
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.startNavigation
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.summaryBottomSheet
import kotlinx.android.synthetic.main.activity_custom_ui_component_style.wayNameView
import kotlinx.android.synthetic.main.fragment_basic_navigation.*
import okhttp3.Cache
import timber.log.Timber
import java.io.File
Expand Down Expand Up @@ -198,16 +206,13 @@ class CustomUIComponentStyleActivity :
isLocationComponentEnabled = true
}

navigationMapboxMap = NavigationMapboxMap(
mapView,
mapboxMap,
this,
true
).apply {
addOnCameraTrackingChangedListener(cameraTrackingChangedListener)
addProgressChangeListener(mapboxNavigation)
setCamera(DynamicCamera(mapboxMap))
}
navigationMapboxMap = NavigationMapboxMap.Builder(mapView, mapboxMap, this)
.vanishRouteLineEnabled(true)
.build().apply {
addOnCameraTrackingChangedListener(cameraTrackingChangedListener)
addProgressChangeListener(mapboxNavigation)
setCamera(DynamicCamera(mapboxMap))
}

if (shouldSimulateRoute()) {
mapboxNavigation
Expand Down
Loading

0 comments on commit 3d3e86f

Please sign in to comment.