Skip to main content

Direction UI

Introduction

MapplsDirectionUI SDK provides the UI components to quickly integrate Route API from MapplsAPIKit framework in iOS application. It offers the following basic functionalities:

  1. Takes support of Mappls's Place search for searching locations of origin, destinations and via points.
  2. It allows to use origin and destinations in Mappls's digital address (semicolon separated) Mappls Pin or WGS 84 geographical coordinates both.
  3. The ability to set the vehicle profile like driving, and biking.
  4. Easily set the resource for traffic and ETA information.

For details, please contact apisupport@mappls.com.

Installation

This plugin can be installed using CocoaPods. It is available with name MapplsDirectionUI.

Using CocoaPods

To install the MapplsDirectionUI using CocoaPods:

Create a Podfile with the following specification:

pod 'MapplsDirectionUI', '0.0.3'

Run pod repo update && pod install and open the resulting Xcode workspace.

Dependencies

This library depends upon several Mappls's own and third party libraries. All dependent libraries will be automatically installed using CocoaPods.

Below are list of dependcies which are required to run this SDK:

Authorization

MapplsAPICore

It is required to set MAPPLS's keys to use any MAPPL's SDK. Please refer the documentation here.

Usage

The MapplsDirectionUI makes it easy to integrate Route from MapplsAPIKit SDK to your iOS application. It gives you all the tools you need to add Directions related UI components to your application.

MapplsDirectionsViewController

MapplsDirectionsViewController is type of UIViewController which you can use to show screen for getting input from user to choose origin and destination and show routes after that.

let directionVC = MapplsDirectionViewController(for: [MapplsDirectionLocation]())
self.navigationController?.pushViewController(directionVC, animated: false)

As from above code you can see it requires an array of object type MapplsDirectionLocation. It can be an blank array to launch screen without any chosen locations.

Also you can pass fixed locations and launch instnace of MapplsDirectionViewController, as shown in below code:

var locationModels = [MapplsDirectionLocation]()
let source = MapplsDirectionLocation(location: "77.2639,28.5354", displayName: "Govindpuri", displayAddress: "", locationType: .suggestion)

let viaPoint = MapplsDirectionLocation(location: "12269L", displayName: "Sitamarhi", displayAddress: "", locationType: .suggestion)

let destination = MapplsDirectionLocation(location: "1T182A", displayName: "Majorganj", displayAddress: "", locationType: .suggestion)

self.locationModels.append(source)
self.locationModels.append(viaPoint)
self.locationModels.append(destination)
let directionVC = MapplsDirectionViewController(for: self.locationModels)
directionVC.profileIdentifier = .driving
directionVC.attributationOptions = [.congestionLevel]
directionVC.resourceIdentifier = .routeETA
self.navigationController?.pushViewController(directionVC, animated: false)

Configuration

Here are the properties use to configure MapplsDirectionViewController route.

Profile Identifier

It is instance of enum DirectionsProfileIdentifier which can accepts values driving, walking, biking, trucking. By default its value is driving.

Resource Identifier

It is instance of enum DirectionsResourceIdentifier which can accepts values routeAdv, routeETA. By default its value is routeAdv.

Note: To use RouteETA ‘resourceIdentifier’ should be routeETA and ‘profileIdentifier’ should be driving. In response of RouteETA a unique identifier to that request will be received which can be get using parameter routeIdentifier of object Route.

AttributeOptions

AttributeOptions for the route. Any combination of AttributeOptions can be specified. By default, no attribute options are specified.

IncludesAlternativeRoutes

A Boolean value indicating whether alternative routes should be included in the response. The default value of this property is true.

autocompleteViewController

MapplsAutocompleteViewController provides an interface that displays a table of autocomplete predictions that updates as the user enters text. Place selections made by the user are returned to the app via the MapplsAutocompleteViewControllerResultsDelegate.

autocompleteAttributionSetting

AutocompleteAttributionSetting allow to change the appearance of the logo in MapplsAutocompleteViewController

autocompleteFilter

This property represents a set of restrictions that may be applied to autocomplete requests. This allows customization of autocomplete suggestions to only those places that are of interest.

routeShapeResolution

A routeShapeResolution indicates the level of detail in a route’s shape, or whether the shape is present at all its default value is .full

includesSteps

A Boolean value indicating whether MapplsRouteStep objects should be included in the response. its default value is true.

isShowStartNavigation

To show the Start Navigation button if the origin is current location.

MapplsDirectionViewController is created using several UI components whose appearance can be changed according to user requirements. Some of them are listed as below:

  • MapplsDirectionTopBannerView
  • MapplsDirectionBottomBannerView

MapplsDirectionViewControllerDelegates

It is a protocol class which will be used for callback methods as shown below:

Call Back Handler

/// This meathod will be called when back button is clicked in `TopBannerView`
1. didRequestForGoBack(for view: MapplsDirectionTopBannerView)

/// The meathod will be called when  add viapoint button will clicked in `TopBannerView`.
2. didRequestForAddViapoint(_ sender: UIButton,for isEditMode: Bool)

/// The meathod will be called when  Directions button will clicked in `BottomBannerView`.
3. didRequestDirections()

//The meathod will be called when  start button will clicked in `BottomBannerView`.
4. didRequestForStartNavigation(for routes: [Route], locations: [MapplsDirectionLocation], selectedRouteIndex: Int, error: NSError)

MapplsDirectionTopBannerView

MapplsDirectionTopBannerView is type of UIView which show the source, destination and viapoint locations at the top of MapplsDirectionViewController

This class accepts array of MapplsDirectionLocation from which it set value of source, destination and viapoint.

MapplsDirectionBottomBannerView

MapplsDirectionBottomBannerView is class of type UIView, it used for showing the route information i.e ArivalTime, DistanceRemening, TimeRemening.

To use this class it takes we need to call a function updateBottomBanner which accepts three parameters i.e route, selectedRoute, locationModel.

  • route: It is an array of the Routes which is required to update bottom banner view.
  • selectedRoute: If you have multiple routes then it will give the selected route in Integer
  • locationModel: LocationModel is an array of the type MapplsDirectionLocation which is required to manage bottom banner view.