-
Notifications
You must be signed in to change notification settings - Fork 0
Home
MapmyIndia’s iOS Raster Map SDK helps to embed MapmyIndia maps within your iOS application. Through customized raster tiles, you can add different map layers to your application and add bunch of controls and gestures to enhance map usability thus creating potent map based solutions for your customers.
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.
Please see branding guidelines on MapmyIndia website for more details.
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.
-
Drag and drop the MapmyIndia Map SDK Framework (Mapbox.framework) to your project. It must be added in embedded binaries.
-
Drag and drop the
MapmyIndiaAPIKit
Framework to your project. It must be added in embedded binaries. It is a dependent framework. -
In the Build Phases tab of the project editor, click the + button at the top and select .New Run Script Phase.. Enter the following code into the script text field: bash
${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework/strip-frameworks.sh
-
For iOS9 or later, make this change to your
info.plist (Project target > info.plist > Add row and set key NSLocationWhenInUseUsageDescription
, NSLocationAlwaysUsageDescription
)
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 the following import statement.
#import <MapmyIndiaAPIKit/MapmyIndiaAPIKit.h>
import MapmyIndiaAPIKit
To initialize SDK you have to set required keys. You can achieve this using
two ways:
First Way (Preferred)
By adding following keys in Info.plist
file of your project MapmyIndiaSDKKey
, MapmyIndiaRestKey
, MapmyIndiaAtlasClientId
, MapmyIndiaAtlasClientSecret
, MapmyIndiaAtlasGrantType
.
Second Way
You can also set these required keys programmatically.
Add the following to your application:didFinishLaunchingWithOptions
: method, replacing restAPIKey
and mapSDKKey
with your own API keys:
[MapmyIndiaAccountManager setMapSDKKey:@"MAP SDK_KEY"];
[MapmyIndiaAccountManager setRestAPIKey:@"REST API_KEY"];
[MapmyIndiaAccountManager setAtlasClientId:@"ATLAS CLIENT_ID"];
[MapmyIndiaAccountManager setAtlasClientSecret:@"ATLAS CLIENT_SECRET"];
[MapmyIndiaAccountManager setAtlasGrantType:@"GRANT_TYPE"]; //always put client_credentials
[MapmyIndiaAccountManager setAtlasAPIVersion:@"1.3.11"]; // Optional; deprecated
MapmyIndiaAccountManager.setMapSDKKey("MAP SDK_KEY")
MapmyIndiaAccountManager.setRestAPIKey("REST API_KEY")
MapmyIndiaAccountManager.setAtlasClientId("ATLAS CLIENT_ID")
MapmyIndiaAccountManager.setAtlasClientSecret("ATLAS CLIENT_SECRET")
MapmyIndiaAccountManager.setAtlasGrantType("GRANT_TYPE") //always put client_credentials
MapmyIndiaAccountManager.setAtlasAPIVersion("1.3.11") // Optional; deprecated
#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
Set zoom to 4 for country level display and 18 for house number display
[mapView setZoom:14];
The following function will display user’s current location on the map.
mapView.showUserLocation=YES;
NSLog(@"User's location: %@", mapView.userLocation);
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
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;
To add a marker, create a MMIAnnotation object that includes a location, title/subtitle and markerImage etc.
MGLPointAnnotation *point = [[MGLPointAnnotation alloc] init];
point.coordinate = CLLocationCoordinate2DMake(28.550834, 77.268918);
point.title = @"Annotation";
[self.mapView addAnnotation:point];
[mapView removeAnnotation:annotation]; // to remove a single marker
[mapView removeAllAnnotations]; // to clear all markers on map
annotation.markerImage=[UIImage imageNamed:@"placemarker.png"]; //formats supported - png,jpg
annotation.makerSize=CGSizeMake(48, 48); //set any size that looks good with your image
MMIAnnotation* annotation=[[MMIAnnotation alloc] init];
annotation.latitude=28.123
annotation.longitude=78.563
annotation.opacity=0.5;
[mapView addAnnotation:annotation];
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;
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;
To create custom callout view create a class inherited from .MGLCalloutView.
and .UIView.
. Override draw function of UIView
to design your own callout view.
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];
[mapView removePolyLine];
Change width of polyline -
mapView.polylineWidth=4.0;
mapView.polylineColor=[UIColor greenColor];
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];
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;
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
Rest API Kit is a iOS wrapper library on MapmyIndia's offered Rest APIs. For more detail go to MapmyIndia's Rest APIs.
For any queries and support, please contact:
Email us at [email protected]
Ask a question under the mapmyindia-api
Need support? contact us!
Read about the latest updates & customer stories
© Copyright 2019. CE Info Systems Pvt. Ltd. All Rights Reserved. | Terms & Conditions
mapbox-gl-native copyright (c) 2014-2019 Mapbox.