IOS Google map SDK tutorial

This is a detailed tutorial given by Google, https://developers.google.com/maps/documentation/ios-sdk/intro, remember to open in the country to open VPN, or it will be wall. But Google tutorials SDK are downloaded with CocoaPods, and in the country will be wall, anyway, in accordance with the official tutorial, I tried N times, have not been successful. Test a lot of methods, encountered a variety of problems, and now share with you!

First: Download SDK
, if you follow the official tutorial, in the terminal when using CocoaPods download will be reported wrong, as follows:

IOS Google map SDK tutorial
reported error

, and I haven’t found any place to download SDK directly at the official website. So it is with CocoaPods,
pod search GoogleMaps in the terminal input, this step as before, while the second step will no longer need to download pods, we manually download, find the link, as shown in figure

IOS Google map SDK tutorial
download link

copy the download link above and open it directly in safari or other browsers, as shown in figure

IOS Google map SDK tutorial
is pasted in the address bar

will then go directly to the download, and so on, download, decompression, will get a project, we only need the inside GoogleMaps.framework

IOS Google map SDK tutorial
GoogleMaps.framework

The second step: to get the API Key
, use Google Maps SDK before you first get a API Key. This means that we need to get a special string from Google so that we can call Google API later from app. This API Key needs to be obtained from the Google Developers Console, which is implied by such a name, which is a place related to developers”. Obviously, you have to have a Google account. If you don’t have an account, start creating one. In another case, if you have a Google account, you can move on smoothly.

To get the API Key used in your application, you can ignore the instructions given here and follow the introductory guidelines given by Google.

Well, let’s get started. Use your Google account, log on to Developers Console, and then build a new project here:

IOS Google map SDK tutorial
creates a new map project
IOS Google map SDK tutorial
takes the name

Once you’ve created it, you’ll see the interface and click on the blue background:

IOS Google map SDK tutorial
hits the red box position

appears to select the SDK interface, and what we need is Google Maps SDK for iOS:

IOS Google map SDK tutorial,
, Google, Maps, SDK, for, iOS

and then let’s select the SDK Enable:

IOS Google map SDK tutorial
Enable

waits for a little session. After success, click where you appear to create the certificate:

IOS Google map SDK tutorial
credentials

select iOS and click Create:

IOS Google map SDK tutorial
selects iOS

input project bundle id:

IOS Google map SDK tutorial
enter bundle ID

waiting to be created, API key comes out, and then clicks Done:

IOS Google map SDK tutorial
API key

The third step:
project configuration to download a good GoogleMaps.framework into the project, when Xcode asked you, please ensure that the Copy items if select needed options, ensure that the three is selected:

IOS Google map SDK tutorial
ensures that the three items are in the selected state

next, go back to Finder and click GoogleMaps.framework again. Select GoogleMaps.bundle from the Resources folder and drag it into the Project Navigator Xcode. When you add this bundle to your project, you have the same choice as the above description.

IOS Google map SDK tutorial
GoogleMaps.bundle

goes here, and the following two items should appear in your project:

IOS Google map SDK tutorial
GoogleMapsSDK

in order for Google Maps SDK to work properly, several other frameworks need to be included in the project. Before I give you the framework and list of static libraries that you have to add, make sure that you select projects in Project Navigator, click Build Phases, and expand the Link Binary With Libraries option. Use the plus (+) button to increase by item by listing:

IOS Google map SDK tutorial
libraries that need to be configured

next, click the Build Setting tab, and look for the Other Linker Flags settings. When you find it, assign the -ObjC to it.

IOS Google map SDK tutorial,
, Other, Linker, Flags

The fourth step:
code 1, import header file in AppDelegate: #import < GoogleMaps/GoogleMaps.h>
– (BOOL) application: (UIApplication * application) didFinishLaunchingWithOptions: (NSDictionary *) method which adds just registered API key

- (BOOL) application: (UIApplication * application) didFinishLaunchingWithOptions: (NSDictionary *) launchOptions point for customization {/ / Override after application launch. [GMSServices provideAPIKey:@ "you apply API key"]; return YES;}

2, add the map
import header file on the page that needs the map: #import < GoogleMaps/GoogleMaps.h>

- (void) viewDidLoad {[super viewDidLoad]; Do any additional setup after loading / the view, typically from a nib. GMSCameraPosition *camera [GMSCameraPosition cameraWithLatitude:22.290664 longitude:114.195304 = zoom:14]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; self.view = mapView_; GMSMarker = *marker [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake (22.290664, 114.195304); marker.title = @ "Hongkong"; marker.snippet = @ "Hong Kong"; marker.map = mapView_;}

Finally, the settings in the plist file,
, need to be configured with the plist file in iOS9

< key> /key> < array> < string> LSApplicationQueriesSchemes< googlechromes< /string> <; string> comgooglemaps< /string> < /array>

In the plist file, configure as follows:

IOS Google map SDK tutorial
plist file configuration

OK, now run the project, and Google Map will come out.

IOS Google map SDK tutorial
Google Map