Skip to main content

Android Native - Itineraries

info

The know the implemented features and the coverage please refers to the Routing API page

Itineraries

The itineraries used in the WemapSDKs are generated by the Wemap Routing API. The way you interact with the Wemap Routing API varies depending on which WemapSDK you use.

When you use:

  • WemapMapSDK use:
    • IMapNavigationManager interface to compute itineraries and start navigation immediately.
    • ItineraryManager class to compute and preview itineraries before starting a navigation.
  • WemapGeoARSDK use:
    • IARNavigationManager interface to compute itineraries and start navigation immediately.
  • WemapCoreSDK use:
    • IItineraryService interface to compute itineraries.

To generate an itinerary, you'll need to provide a destination, optionally origin and other options depending on which WemapSDK you use. You also can use the ItinerarySearchOptions class to set a few search options. Wemap Routing API provides different travel modes for itinerary computation: Walk, Car and Bike. Bike travel mode also can have TravelMode.Preference: DEFAULT, SAFEST, FASTEST and TOURISM.

Map Navigation Manager (WemapMapSDK)

To generate an itinerary and start navigation, you'll need to obtain an instance implementing IMapNavigationManager from MapView.

private fun startNavigation() {

val origin = Coordinate(43.610628, 3.876654)
val destination = Coordinate(43.609011, 3.917091)

val navigationOptions = NavigationOptions(stopWhenArrivedAtDestination = false) // NavigationOptions available for Map and AR SDKs
val itineraryOptions = ItineraryOptions(indoorLine = LineOptions(color = Color.RED)) // ItineraryOptions available only for WemapMapSDK
val searchOptions = ItinerarySearchOptions(avoidStairs = true) // ItinerarySearchOptions available for all SDKs

mapView.navigationManager
.startNavigation(
origin, destination,
TravelMode.Walk(), // can be omitted because it's default mode
navigationOptions,
searchOptions,
itineraryOptions,
10 // default value is 30 seconds
)
.subscribe({
println("Successfully started navigation from: $origin to: $destination")
}, {
println("Failed to start navigation from $origin to: $destination with error: $it")
})
.disposedBy(disposeBag)
}

Itinerary manager (WemapMapSDK)

To generate an itinerary for preview, you'll need to obtain an instance of ItineraryManager class from MapView.

private fun getItinerariesForPreview() {

val origin = Coordinate(43.610628, 3.876654)
val destination = Coordinate(43.609011, 3.917091)

val searchOptions = ItinerarySearchOptions(avoidStairs = true) // ItinerarySearchOptions available for all SDKs

mapView.itineraryManager
.getItineraries(
origin,
destination,
TravelMode.Walk(), // can be omitted because it's default mode
searchOptions
)
.subscribe({
println("Successfully started navigation from: $origin to: $destination")
mapView.locationManager.cameraMode = CameraMode.TRACKING_COMPASS // track user movements
mapView.itineraryManager.addItinerary(it.first()) // draw preview
}, {
println("Failed to start navigation from $origin to: $destination with error: $it")
})
.disposedBy(disposeBag)
}

AR Navigation Manager (WemapGeoARSDK)

To generate an itinerary and start navigation, you'll need to obtain an instance implementing IARNavigationManager from GeoARView.

 private fun startNavigation() {

val origin = Coordinate(43.610628, 3.876654)
val destination = Coordinate(43.609011, 3.917091)

val navigationOptions = NavigationOptions(stopWhenArrivedAtDestination = false) // NavigationOptions available for Map and AR SDKs
val searchOptions = ItinerarySearchOptions(avoidStairs = true) // ItinerarySearchOptions available for all SDKs

geoARView.navigationManager
.startNavigation(
origin, destination,
TravelMode.Walk(), // can be omitted because it's default mode
navigationOptions,
searchOptions,
10 // default value is 30 seconds
)
.subscribe({
println("Successfully started navigation from: $origin to: $destination")
}, {
println("Failed to start navigation from $origin to: $destination with error: $it")
})
.disposedBy(disposeBag)
}

Itinerary Service (WemapCoreSDK)

To generate an itinerary, you'll need to obtain an instance implementing IItineraryService and request for itinerary computation using ItineraryParameters class.

Below are examples of how you can use specific options to compute itineraries for a few scenarios.

Compute itinerary

This example demonstrates how to calculate walking itineraries with origin and destination coordinates.

private fun computeItineraries() {

val origin = Coordinate(43.610628, 3.876654)
val destination = Coordinate(43.609011, 3.917091)

val parameters = ItineraryParameters(origin, destination) // default travelMode is Walk()

service
.itineraries(parameters)
.subscribe({
println("response - $it")
setupItinerary(it.itineraries.first())
}, {
println("error - $it")
})
.disposedBy(disposeBag)
}

You can specify travel mode and preference for the request:

private fun computeItineraries() {
...
val parameters = ItineraryParameters(origin, destination, TravelMode.Bike(TravelMode.Preference.SAFEST))
...
}

Also is some cases you may need to specify search options:

private fun computeItineraries() {
...
val parameters = ItineraryParameters(origin, destination, TravelMode.Walk(), ItinerarySearchOptions(avoidStairs = true))
...
}

Examples

For additional examples and sample implementations of WemapSDKs, visit the official GitHub repository.

Clone the repository and follow the README instructions to run the sample application.