Include the Library in Your Xcode Project
You can find the Bing Maps iOS Control (as a universal static library) plus the required resources bundle and header files in the MapControl folder of your SDK installation.
- Right-click on the project file and choose Add Files to "<Project>".... Navigate to the MapControl folder, and select all items. Click Add.
- Left-click on the project file and click on the Build Settings tab.
- Set the value of the Header Search Paths environment variable to the path to your MapControl directory (for example,
/Users/{username}/Documents/BingMapsiOS/MapControl/
).
Note: If there are any spaces in the path, be sure to enclose the entire path with double quotes (").
Add Linker Flags
- Left-click on the project file and click on the Build Settings tab.
- Set the value of the Other Linker Flags environment variable to
-ObjC -all_load
.
Add Required Frameworks
- Left-click on the project file. Select the target of your project and select the Build Phases tab.
- Click to expand the Link Binary With Libraries item and click the [+] on the bottom to add frameworks. Select the following frameworks:
- CoreData.framework
- CoreLocation.framework
- OpenGLES.framework
- QuartzCore.framework
- SystemConfiguration.framework
- libxml2.dylib
- libz.dylib
Inserting the Map Control in a NIB File
- Open up the NIB file (.xib) where you want to insert the map in Interface Builder. From the Library palette, select the Objects tab and drag the UIView control to the space where you want the map to appear.
- With the UIView control selected, tick the Multiple Touch checkbox within the Interaction section of the Inspector palette.
- Click on the Identity tab of the Inspector palette. For the Class item, type in
BMMapView
.
- Save the file in Interface Builder.
Implementing the BMMapView Delegate in UIViewController
#import "BingMaps/BingMaps.h"
- Go to the ViewController class file and add the following code in the viewDidLoad: method.
- (void)viewDidLoad {
[super viewDidLoad];
[mapView setDelegate:self];
[mapView setShowsUserLocation:YES];
}
- Save and build your project.
- Open up the NIB file (.xib) where you want to insert the map in Interface Builder. Ctrl + drag from the File's Owner item in the Document window to the BMMapView you created earlier and select mapView in the Outlets pop-up.
- Save the file in Interface Builder.
Adding Your Bing Maps Key
To use the Bing Maps iOS Control, you need to have a Bing Maps Key to use in your app.
Bing Maps Keys can be requested from the Bing Maps Account Center (http://www.bingmapsportal.com). More information is available at http://msdn.microsoft.com/en-us/library/ff428642.aspx
Once you have a Bing Maps Key, follow the steps below to add it to your app project's main property list, named {appname}_Info.plist
- In the property list, click the [+] at the bottom-right to add a new row. The key should be specified as BingMapsKey and the value should be your Bing Maps Key.
Session Counting
When the Bing Maps iOS Control is loaded with a valid Bing Maps Key, Bing Maps counts sessions. A session begins with the load of the first Bing Maps iOS Control which appears in an app and includes all map control interactions until the app is terminated. Information about Bing Maps usage reports is found in the Viewing Bing Maps Usage Reports topic.