iOS SDKs

Vector-based map data, provides mapping capabilities with features such as routing, navigation, historical traffic patterns

MapmyIndia Map iOS SDK

Getting Started

MapmyIndia Maps SDK for IOS lets you easily add MapmyIndia Maps and web services to your own iOS app. MapmyIndia Maps SDK for iOS supports iOS SDK 7.1 and above and Xcode 6.0.1 or later. You can have a look at the map and features you will get in your own app by using the MapmyIndia Maps app for iOS. The SDK handles map tiles download and their display along with a bunch of controls and native gestures.

API Usage

Your MapmyIndia Maps SDK usage needs a set of license keys (get them here) and is governed by the API terms and conditions. As part of the terms and conditions, you cannot remove or hide the MapmyIndia logo and copyright information in your project.

The allowed SDK hits are described on the plans page. Note that your usage is shared between platforms, so the API hits you make from a web application, Android app or an iOS app all add up to your allowed daily limit.

Setup your project

  • Create a new project in Xcode
  • Drag and drop the MapmyIndia Map SDK framework (MMIFramework.framework) and resource bundle file (MMIFramework.bundle) to your project
  • Add these dependencies to your project (Build Phases > Link Binary with Libraries) -
    • libsqlite3.0.dylib
    • libz.dylib
  • Add compiler flag (Project target > Build Settings > Other Linker Flags > Set `-ObjC`)
  • For iOS8 or later, make this change to your info.plist (Project target > info.plist > Add row and set key `NSLocationWhenInUseUsageDescription`)
  • Add your MapmyIndia Map API keys to your AppDelegate.m as follows-
      1. Add the following import statement
        #import <MMIFramework/MMIFramework.h>
      2. Add the following to your application:didFinishLaunchingWithOptions: method, replacing restAPIKey and mapSDKKey with your own API keys:
        [LicenceManager sharedInstance].restAPIKey=your_rest_api_key;
        [LicenceManager sharedInstance].mapSDKKey=your_java_script_key;

Add a MapmyIndia Map

#import <MMIFramework/MMIFramework.h>
@interface MapViewController : UIViewController
{
MMIMapView* mapView;

}
@end

@implementation MapViewController

- (void)viewDidLoad {
   [super viewDidLoad];
mapView = [MMIMapView alloc] 
initWithFrame:self.view.frame];
    [self.view addSubview:mapView];
}
@end

Map Interactions

Set Zoom Level

//Set zoom to 4 for country level display and 18 for house number display
[mapView setZoom:14];

Current Location

The following function will display user’s current location on the map.

mapView.showUserLocation=YES;

NSLog(@"User's location: %@", mapView.userLocation);

Map Events

The Map object should implement the methods of the MMIDelegate protocol corresponding to the events you wish it to receive. This delegate can also be used to detect map overlays selection. Delegate handles gesture events, tap on annotation (marker), long press on map and map center coordinates.

-(void)mapViewRegionDidChange:(MMIMapView *)mapView;
-(void)afterMapMove:(MMIMapView *)map byUser:(BOOL)wasUserAction;
-(void)afterMapZoom:(MMIMapView *)map byUser:(BOOL)wasUserAction;
-(void)tapOnAnnotation:(MMIAnnotation *)annotation onMap:(MMIMapView *)mapView

Map Tap/Long Press

To capture single tap on map events, use singleTapOnMap method from MMIDelegate -

- (void)singleTapOnMap:(MMIMapView *)map at:(CGPoint)point;

For long press event, use longPressOnMap method of MMIDelegate -

- (void)longPressOnMap:(MMIMapView *)map at:(CGPoint)point;

Map Overlays

Markers

Add a Marker
To add a marker, create a MMIAnnotation object that includes a location, title/subtitle and markerImage etc.

MMIAnnotation* annotation=[[MMIAnnotation alloc] init];
annotation.latitude=28.526;
annotation.longitude=78.568;
annotation.title=@"Delhi" ; //the title is shown in the info window as described below
[mapView addAnnotation:annotation];

Remove a Marker

[mapView removeAnnotation:annotation]; // to remove a single marker

[mapView removeAllAnnotations]; // to clear all markers on map

Change default marker icon

annotation.markerImage=[UIImage imageNamed:@"placemarker.png"]; //formats supported - png,jpg
annotation.makerSize=CGSizeMake(48, 48); //set any size that looks good with your image

Marker Opacity

MMIAnnotation* annotation=[[MMIAnnotation alloc] init];
annotation.latitude=28.123
annotation.longitude=78.563
annotation.opacity=0.5;
[mapView addAnnotation:annotation];

Info Windows

Enable display of info windows on annotation tap event.

MMIAnnotation* annotation=[[MMIAnnotation alloc] init];
annotation.latitude=28.123
annotation.longitude=78.563
annotation.title=@"Welcome";
annotation.canShowCallout=YES;
annotation.opacity=1.0;

Marker Clustering

To enable auto-clustering on all markers displayed on map, set the value to True. Default is False. See marker clustering in action in the samples bundled in the SDK.

mapView.clusteringEnabled=NO;

Polylines

Add a Polyline

NSArray *locations = [NSArray arrayWithObjects:
[[CLLocation alloc] initWithLatitude:28.54937553 longitude:77.26795197],
[[CLLocation alloc] initWithLatitude:28.54939461 longitude:77.26816559],
[[CLLocation alloc] initWithLatitude:28.54946899 longitude:77.26811981],
[[CLLocation alloc] initWithLatitude:28.54972458 longitude:77.26800537],nil];
[mapView drawPolyLine:locations];

Remove a Polyline

[mapView removePolyLine];

Customize a Polyline
Change width of polyline -

mapView.polylineWidth=4.0;

Change color of polyline –

mapView.polylineColor=[UIColor greenColor];

Polygons

Add a Polygon

NSMutableArray* polygonVertices = [[NSMutableArray alloc] initWithCapacity:50]; 

CLLocation* location1=[[CLLocation alloc] initWithLatitude:26.613434longitude:75.758556]; 
CLLocation* location2=[[CLLocation alloc] initWithLatitude:26.311922longitude:76.492635]; 
CLLocation* location3=[[CLLocation alloc] initWithLatitude:26.230916longitude:76.130366]; 
CLLocation* location4=[[CLLocation alloc] initWithLatitude:26.364601longitude:75.832132]; 
CLLocation* location5=[[CLLocation alloc] initWithLatitude:26.613434longitude:75.758556];
  
[polygonVertices addObject:location1]; 
[polygonVertices addObject:location2]; 
[polygonVertices addObject:location3]; 
[polygonVertices addObject:location4]; 
[polygonVertices addObject:location5];     
[mapViewdrawPolyLine:polygonVertices];

Circles

Add a Circle
You must specify the following parameters to add a circle on the map –

  • position (latitude, longitude)
  • radiusInMeters (in meters)
  • lineWidthInPixels (width of circle stroke)
MMIAnnotation* annotation=[[MMIAnnotationalloc] init];
annotation.latitude=28.526;
annotation.longitude=78.568;
annotation.radiusInMeters=500; 
annotation.lineWidthInPixels=5;
Customize a Circle
annotation.lineColor=[UIColor redColor]; //change the stroke color of the circle
annotation.fillColor=[UIColor colorWithRed:.5 green:.466 blue:.733 alpha:.25]; //change the fill color of the circle
Search

The following search services are available as part of the SDK bundled by default (Make sure you include following import in your code) –

#import <MMIFramework/MMIFramework.h>

Geocoding

You can read more on MapmyIndia's Geocoding API. To geocode an address, create an instance of GeocodeManager class and call the getPlace method –


GeocodeManager *managerObject = [[GeocodeManager alloc] init];
[managerObject getPlace:@“New Delhi” completion:^(NSDictionary *result,NSError* error){
 
  // if error is nil, then result is success.    
 
 // response includes responseCode,version and results Array   
 
}];

Reverse Geocoding

You can find address for a point on the map by using the MapmyIndia Maps Reverse Geocoding API. Pass the GeoPoint to the ReverseGeocodeManager class –

ReverseGeocodeManager *reverseGeoCodeManagerObject=[[ReverseGeocodeManager alloc]init];    
 [reverseGeoCodeManagerObject getPlace:CLLocationCoordinate2DMake(startPoint, finalPoint) completion:^(NSDictionary *result,NSError* error){ 
 // if error is nil, then result is success.  // response is the results array      
}];

Routes & Navigation

adasdas

Routing API

Driving Distance Matrix API

Telematics

Beacon

MapmyIndia Beacon SDK is primarily used for developing location-aware applications. This will help the user to review where your device has been. Location send frequency in the Beacon SDK depends on the selected profile.
3 different pre-defined profiles are :

  1. Vehicle : Very frequent polling i.e. in every 5 seconds.
  2. People : Relaxed polling i.e. in every 15 minutes or 900 seconds.
  3. Hybrid : Mixed polling i.e. in every 5 minutes or 300 seconds.

Please note, use of the profiles depends upon the desired requirement. For example if distance needs to be measured, then suggested profile is vehicle. Although due to frequent GPS and GPRS use, battery of the device may drain out quicker in vehicle profile.

Getting Started

It is recommended that you use Android Studio as your IDE for development. MapmyIndia Beacon SDK for Android supports Android API version 10 and above. You can send location information from your app by using the MapmyIndia Beacon SDK. The SDK provides control features in terms starting and stopping the Beacon service.

MapmyIndia Intouch API key can be obtained from your API dashboard. This key will enable you to access different components of Beacon SDK.

Note : Beacon SDK will work on those devices which have GSM module i.e a valid IMEI number.

Data Management​

Currently if the location module of the device is not able to get any location from GPS or Cell network then no position is reported from the device.

API Usage

Your MapmyIndia Beacon SDK usage needs a set of license keys and is governed by the API terms and conditions.

Setup your project:
Follow these steps to add the SDK to your project –
  • Create a new project in Android Studio
  • Copy the SDK jar file to project libs/ folder
  • Add the following permissions to your AndroidManifest.xml file.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

and following in application tag

<service android:name="com.mmi.beacon.service.BeaconTrackerService"/>
<receiver android:name="com.mmi.beacon.receiver.NetworkChangeReceiver" />
<intent-filter/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="com.mmi.beacon.LOGGER"/>
 <action android:name="android.intent.action.BOOT_COMPLETED" />
 <action android:name="android.intent.action.QUICKBOOT_POWERON" />
 <intent-filter/>
 <receiver/>

Add your API keys to the SDK
Make the following function calls in the Application Class -

LicenceManager.getInstance().setMapmyIndiaBeaconToken(Your_token);
public class DemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
LicenceManager.getInstance().setMapmyIndiaBeaconToken(Your_token);
}
}

Note: You should not use the MapmyIndia Beacon SDK without these function calls. You will find your keys in your API Dashboard.

Class: MapmyIndiaBeacon
Steps to integrate:

1. Need to register device with “RegisterDeviceListener”

MapmyIndiaBeacon.getInstance(getActivity()).registerDevice(resultCode,deviceName,listener);

On successful registration you will receive a callback in “onRegistration(trackingCode)”.
If registration is failed,
public void onError(int resultCode, int errorCode, String message)” will be called.
resultCode” is same what you pass while calling “registerDevice”.
List of “errorCode

public static int INTERNET_ERROR = 1001;
public static int INVALID_TOKEN_ERROR = 1002;
public static int DEVICE_NOT_FOUND_ERROR = 1003;
public static int OTHER_ERROR = 1004;

List of “message” for errors.

public static String MSG_INVALID_TOKEN_ERROR = "Invalid token";
public static String MSG_OTHER_ERROR = "Something went wrong";

2. Once successful, user can call “startBeacon” function as follows

MapmyIndiaBeacon.getInstance(getActivity()).startBeacon(MapmyIndiaBeacon.TrackingProfile.PEOPLE);
Possible values of “startBeacon” parameters
MapmyIndiaBeacon.TrackingProfile.PEOPLE
MapmyIndiaBeacon.TrackingProfile.HYBRID
MapmyIndiaBeacon.TrackingProfile.VEHICLE
3. User can call “stopBeacon” function as follows
MapmyIndiaBeacon.getInstance(getActivity()).stopBeacon();

Live Location






Trips & Drive




Geofence & Routes






Alerts