Navigation SDK - iOS
Specifications
- Minimum iOS version: iOS 13.0
- Xcode Version: 12 or later
Sample App
Please refer to theGithub Sample Appfor getting better clarity on same.
Setup Map
xcframeworks
in your iOS project. Make sure you embed
all the frameworks in General > Frameworks, Libraries and Embedded Content.
Next, You need to add Location Permission Authorization in your Info.plist file,Parameter name | Description |
---|---|
apikey | API Key from Platform Dashboard |
tileURL | Refer Tiles API in API Reference |
projectId | Refer Dashboard for Project Identifier |
userId | Custom UserID which is identified by Organization |
Load the map using the service instance. Ideally this method should be called in viewdidLoad()
method of viewcontroller
Annotation
To draw an annotation, we need to call setAnnotationMarker
with coordinate and Annotation View. Make sure, you have unique Identifier for every nnotation you have on map.
Add Annotation
If you want to show the annoattion on the map you can use CustomAnnotationView andsetAnnotationMarker
Remove Annotation
You can remove a marker from the map by calling this method removeAnnotation.
Polygons
Polygons are designed to define solid regions within a closed loop which can be used to mark a particular zone. They consist of a series of coordinates in an ordered sequence.
You can draw Polygons by calling this method drawPolygon()
, here is the example below:
To draw circle call this method drawCircle()
, here is the example below:
Polyline
Polylines allow you to draw lines on the map. The below example demonstrates how to draw a polyline.
Listening to events
We can listen to 2 types of event
- Longpress event
- Tap event
- MapRegion changed event
Tap and Longpress Events
To listen to events, you must implement the OlaMapServiceDelegate protocol. Typically, you implement this protocol on the view controller that displays the map. Below is an example:
Map Region changed Events
Using the OlaMapServiceDelegate, you can listen when map region changes. Gesture param with it signifies the reason for change
Navigation
Enhance your mobile app with seamless, turn-by-turn navigation. Harness the capabilities of Ola Maps to deliver real-time navigation with intuitive voice guidance. You can instantiate navigation service as follows
Parameter name | Description |
---|---|
apikey | API Key from Platform Dashboard |
tileURL | Refer Tiles API in API Reference |
projectId | Refer Dashboard for Project Identifier |
userId | Custom UserID which is identified by Organization |
Route Data
To enable navigation, you must supply route data to the navigation service. This data can be obtained from the Direction Service.
Please refer to theAPI documentationfor further details.
Navigation Features
- Manage Navigation
- Navigation callbacks
- Instructions
Manage Navigation
- Start Navigation
- End Navigation
Once Route data is fetched from above section, we can call navigate()
api on navigation service to display route and start navigation using following code snippet
Once navigation has been started it can be terminated any time using following api
Navigation callbacks
You can listen to navigation events using the OlaMapNavigationServiceDelegate protocol. Below is an example:
Instructions
- Text Instructions
- Audio Instructions
Once Navigation starts, user will get callbacks depending on journey progress he is making
We can enable audio guide for user during journey using following api. Also Voice guidance can be programatically toggled using toggleVoiceNavigation() api
To get callback of when instructions has been played, implement following method from OlaMapNavigationServiceDelegate
Dependencies
OlaMapNavigationSDK is dependent on following Dependencies