Skip to content

MapplsDrivingRangePlugin for iOS

Introduction

The MapplsDrivingRangePlugin allows you to plot driving range area to drive based on time or distance on Mappls's vector map component.

The plugin offers the following basic functionalities:

  • Get and Plot driving range as polygon on map.

  • Update driving range on map.

  • Clear already plotted driving range on map.

This can be done by following simple steps.

Step 1:-

Installation

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL

  https://github.com/mappls-api/mappls-drivingrange-plugin-ios-distribution.git

See Adding Package Dependencies to Your App.

Version History

Version Dated Description
2.0.0 10 Jun 2025 - Updated minimum iOS deployment target to 13.0 - Authentication and authorization mechanisms have been revised.
--- --- ---
1.0.2 29 Jun, 2023 API wrappers are moved to MapplsAPIKit and so minimum dependency changed.
1.0.1 08 Jul, 2022 Issue fixed where SDK was not compatible to Xcode 13+. MapplsDrivingRangePlugin is renamed to MapplsDrivingRange and Protocol class MapplsDrivingRangePluginDelegate is renamed to MapplsDrivingRangeDelegate.
1.0.0 14 Jun, 2022 Initial MAPPLS release.

Dependencies

This library depends upon several Mappls's own 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 keys to use any MAPPL's SDK. Please refer the documenatation here.

Step 2:-

Plugin Initialization

MapplsDrivingRangePlugin

MapplsDrivingRange is the main class which is need to initialize to use different functionality of plugin. It requires an instance of MapplsMapView.

It allows you to plot driving range area to drive based on time or distance.

var drivingRangePlugin = MapplsDrivingRange(mapView: self.mapView)

self.drivingRangePlugin.delegate = self // optional

Step 3:-

Get And Plot Driving Range

A function getAndPlotDrivingRange of instance of MapplsDrivingRange will be used to get driving range and plot on map. This function will accept an instance of MapplsDrivingRangeOptions as request to get driving range.

Below is code for reference:

let location = CLLocation(latitude: 28.551060, longitude: 77.268989)

let contours = [MapplsDrivingRangeContours(value: 2)]
let rangeInfo = MapplsDrivingRangeRangeTypeInfo(rangeType: .distance, contours: contours)

let drivingRangeOptions = MapplsDrivingRangeOptions(location: location, rangeTypeInfo: rangeInfo)

self.drivingRangePlugin.getAndPlotDrivingRange(options: drivingRangeOptions)

Additional Features

Clear Driving Range

Plotted driving range on Map can be removed by calling function clearDrivingRangeFromMap.

Below is line of code to use it:

drivingRangePlugin.clearDrivingRangeFromMap()

Update Driving Range

Plotted driving range on map can be upated by calling function getAndPlotDrivingRange again with new request object (instance of MapplsDrivingRangeOptions).

Below is some code for reference:

let location = CLLocation(latitude: 28.612972, longitude: 77.233529)

let contours = [MapplsDrivingRangeContour(value: 15)]
let rangeInfo = MapplsDrivingRangeRangeTypeInfo(rangeType: .time, contours: contours)

let speedInfo = MapplsDrivingRangeOptimalSpeed()

let drivingRangeOptions = MapplsDrivingRangeOptions(location: location, rangeTypeInfo: rangeInfo, speedTypeInfo: speedInfo)

self.drivingRangePlugin.getAndPlotDrivingRange(options: drivingRangeOptions)

Reference

MapplsDrivingRangeDelegate

It is a protocol class which provides different callbacks of events of MapplsDrivingRange.

Below are different callback functions avaialble:

drivingRange(_:didFailToGetAndPlotDrivingRange:)

Called when the plugin fails to get and plot driving range.

DECLARATION

optional func drivingRange(_ plugin: MapplsDrivingRange, didFailToGetAndPlotDrivingRange error: Error)

PARAMETERS

  • plugin:- The plugin that has calculated a driving range.

  • error:- An error raised during the process of obtaining a new route.

drivingRangeDidSuccessToGetAndPlotDrivingRange(_:)

Called when the plugin succeed to get and plot driving range on map.

DECLARATION

@objc optional func drivingRangeDidSuccessToGetAndPlotDrivingRange(_ plugin: MapplsDrivingRange)

PARAMETERS

  • plugin:- The plugin that has calculated a driving range.

Our many happy customers:

For any queries and support, please contact:

Email us at apisupport@mappls.com

Support Need support? contact us!


@ Copyright 2022 CE Info Systems Pvt. Ltd. All Rights Reserved.