Ola Map SDK offers a robust toolkit for seamlessly integrating both basic and advanced mapping features into your iOS applications. By utilizing the Maps SDK for iOS, you can incorporate maps powered by Ola's data directly into your app. The SDK takes care of displaying the map and responding to user interactions like clicks and drags. Additionally, you can enhance your maps by adding markers, polylines, ground overlays, and info windows, which provide extra information for specific locations and enable user interaction with the map.
Specifications
Before proceeding, ensure that you meet the following prerequisites:
Minimum iOS version: iOS 13.0
Xcode Version: 12 or later
Sample App
Please refer to theGithub Sample Appfor getting better clarity on same.
Set up
You have to iOS Map SDK import all the 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,
<key>NSLocationWhenInUseUsageDescription</key><string>App wants to access your location</string><key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>App wants to access your location</string>
Now, you are good to initialize the OlaMapService instance in your view controller.
Load the map using the service instance. Ideally this method should be called in viewdidLoad() method of viewcontroller
Features
Dynamic Maps
Camera and View
Polyline
Shape
Marker
Info Window
Map Events and Gesture
Traffic Polyline
Marker Clustering
Dynamic Map
To render a map, you need to initialise OlaMapService first and then call loadMap(_:)
You can control the Map POV area and bounds area which you want to show.
// Set Camera With Single Coordinate olaMap.setCamera(at: OlaCoordinate(latitude: 12.93177, longitude: 77.616370000000003), zoomLevel: 16.0)
// Set Camera With Array of Coordinateslet polylineSetOlaToKormangla: [OlaCoordinate] = [
OlaCoordinate(latitude: 12.93177, longitude: 77.616370000000003),
OlaCoordinate(latitude: 12.93168, longitude: 77.616870000000006)
]
olaMap.setMapCamera(polylineSetOlaToKormangla, UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8))
Events and Gestures
This will enable rotation selection capability on Map, you can rotate the map by using two fingers.
olaMap.setRotatingGesture(true)
Then, You will set of extra gesture delegate callback which comes with OlaMapServiceDelegate
funcdidTapOnMap(_coordinate: OlaCoordinate) {
//TODO: If You tap on tile }
funcdidTapOnMap(feature: POIModel) {
//TODO: If You tap on any POI }
funcdidLongTapOnMap(_coordinate: OlaCoordinate) {
//TODO: If You long press on tile }
funcdidChangeCamera() {
print("Map Camera Change")
}
funcmapSuccessfullyLoaded() {
print("Map Loaded Successfully")
}
funcmapSuccessfullyLoadedStyle() {
print("Map Loaded Style")
}
Info Window
You can draw a Info Window which is a tool tip kind of view on Map.
let toolTipId ="tool-tip"let infoWindow =InfoAnnotationView(identifier: toolTipId, model: InfoAnnotationDecorator(), text: "I'm at OlaCampus", isActive: true)
self.olaMap.setAnnotationMarker(at: self.olaCampus, annotationView: infoWindow, identifier: toolTipId)
And, to delete Info Window you can use
olaMap.removeAnnotation(by:"Annotation-ID")
Map Region Bounds
You can control the Map Visible Bounds when you have array of coordinates.
Along with Solid Polyline, we have the capability to draw Segmented Polyline. This data you will get from Directions API. Check Platform Documentation.
We have a capability to cluster markers under a single labled marker. In simple words, if you've large marker rendered in a single area, then map will automatically cluster them in a single marker with a label on in.