Skip to main content

Itineraries

info

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

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 ItinerarySearchRules class to set a few search rules. 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.

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 searchRules = ItinerarySearchRules.WHEELCHAIR // ItinerarySearchRules available for all SDKs

mapView.navigationManager
.startNavigation(
origin, destination,
TravelMode.Walk(), // can be omitted because it's default mode
navigationOptions, searchRules, 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.

fun getItinerariesForPreview() {

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

val searchRules = ItinerarySearchRules.WHEELCHAIR // ItinerarySearchRules available for all SDKs

mapView.itineraryManager
.getItineraries(
origin, destination,
TravelMode.Walk(), // can be omitted because it's default mode
searchRules
)
.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.

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 searchRules = ItinerarySearchRules.WHEELCHAIR // ItinerarySearchRules available for all SDKs

geoARView.navigationManager
.startNavigation(
origin, destination,
TravelMode.Walk(), // can be omitted because it's default mode
navigationOptions, searchRules,
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.

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:

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

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

fun computeItineraries() {
...
val parameters = ItineraryParameters(
origin, destination, TravelMode.Walk(), ItinerarySearchRules.WHEELCHAIR
)
...
}

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.