Monday 4 August 2014

Jogendra Singh

Route path drawing using Google Map with iOS Sdk

Getting the Google Maps SDK for iOS

Before starting I want to tell, I have already done a example for this you can find this here...

Example Download Form Here

Click Here : - Google-Route-Path-Draw-Using Google Map

The Google Maps SDK for iOS is distributed as a zip file containing a static framework. After downloading the SDK, you will need to obtain an API key before you can add a map to your application.
Complete release notes are available for each release.

The Google Maps API Key

Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. The key is free, you can use it with any of your applications that call the Maps API, and it supports an unlimited number of users. You obtain a Maps API key from the Google APIs Console by providing your application's bundle identifier. Once you have the key, you add it to your AppDelegate as described in the next section.

The Google Maps URL scheme is available without an API key.

Obtaining an API Key

You can obtain a key for your app in the Google APIs Console.
  1. Create an API project in the Google APIs Console.
  2. Select the Services pane in your API project, and enable the Google Maps SDK for iOS. This displays the Google Maps Terms of Service.
  3. Select the API Access pane in the console, and click Create new iOS key.
  4. Enter one or more bundle identifiers as listed in your application's .plist file, such as com.example.myapp.
  5. Click Create.
  6. In the API Access page, locate the section Key for iOS apps (with bundle identifiers) and note or copy the 40-character API key.
You should repeat this process for each new application.

Adding the Google Maps SDK for iOS to your project

The Google Maps SDK for iOS is packaged as a static framework with an included resource bundle. Before you can add a map to your application, you will need to add the framework to your project, and configure your build settings in Xcode. These instructions assume an installation for a new project. If you are working with an existing project, you may not have to follow the steps exactly as described.
  1. Launch Xcode and either open an existing project, or create a new project.
    • If you're new to iOS, create a Single View Application, and disable Use Storyboards but ensure that Use Automatic Reference Counting is on.
  2. Drag the GoogleMaps.framework bundle to the Frameworks group of your project. When prompted, select Copy items into destination group's folder.
  3. Right-click GoogleMaps.framework in your project, and select Show In Finder.
  4. Drag the GoogleMaps.bundle from the Resources folder to your project. We suggest putting it in the Frameworks group. When prompted, ensure Copy items into destination group's folder is not selected.
  5. Select your project from the Project Navigator, and choose your application's target.
  6. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks:
    • AVFoundation.framework
    • CoreData.framework
    • CoreLocation.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.dylib
    • libicucore.dylib
    • libz.dylib
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
  7. Choose your project, rather than a specific target, and open the Build Settings tab.
    • In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar fromBasic to All.
  8. Finally, add your API key to your AppDelegate.
    • #import <GoogleMaps/GoogleMaps.h>
    • Add the following to your application:didFinishLaunchingWithOptions: method, replacing API_KEY with your API key.
      [GMSServices provideAPIKey:@"API_KEY"];

  • Upgrade from an earlier version

    To upgrade an existing project to the most recent version of the SDK, do the following:
    1. In the Project Navigator, replace the previous framework with the most recent framework.
    2. (Optional) Make any necessary changes as a result of the upgrade. Necessary changes will be described in the release notes.
    3. Clean and rebuild your project by selecting: Product > Clean and then Product > Build.

    Add a Map

    After adding the SDK to your project, and adding your key, you can try adding a map to your application. The code below demonstrates how to add a simple map to an existing ViewController. If you're creating a new app to iOS, first follow the installation instructions above, and create a new Single View Application; disabling Use Storyboards but enabling Use Automatic Reference Counting (ARC).
    Now, add or update a few methods inside your app's default ViewController to create and initialize an instance of GMSMapView.
    #import "YourViewController.h"
    #import <GoogleMaps/GoogleMaps.h>
    @implementation YourViewController {
      GMSMapView *mapView_;
    - (void)viewDidLoad {
      // Create a GMSCameraPosition that tells the map to display the
      // coordinate -33.86,151.20 at zoom level 6.
      GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
      mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
      mapView_.myLocationEnabled = YES;
      self.view = mapView_;
      // Creates a marker in the center of the map.
      GMSMarker *marker = [[GMSMarker alloc] init];
      marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
      marker.title = @"Sydney";
      marker.snippet = @"Australia"; = mapView_;
    Note: Replace both instances of YourViewController in the above example with the name of your View Controller.
    Run your application. You should see a map with a single marker centered over Sydney, Australia. If you see the marker, but the map is not visible, confirm that you have provided your API key.
  • Jogendra Singh

    About Jogendra Singh -

    I'm Founder of Jogendra.Com. I love to share my bright ideas with the whole blogging community. I'm a good iPhone Application Developer. Apart from Blogging, I love to play Cricket and mobile games (Clash of clans).

    Subscribe to this Blog via Email :