SlideShare a Scribd company logo
1 of 32
Download to read offline
Google Map SDK for iOS
Michael Pan
13年8月12⽇日星期⼀一
Official Web Page
http://bit.ly/12j2w8r
13年8月12⽇日星期⼀一
We want to build
13年8月12⽇日星期⼀一
Get Google Map API Key
• 從 Google APIs Console 產⽣生 API 專案.
13年8月12⽇日星期⼀一
Google API Console - My Project
13年8月12⽇日星期⼀一
Services
≈
13年8月12⽇日星期⼀一
Create new iOS Key
13年8月12⽇日星期⼀一
Configure Project
• Input bundle ID
13年8月12⽇日星期⼀一
API Console Updated
13年8月12⽇日星期⼀一
Download SDK
• https://dl.google.com/geosdk/GoogleMaps-iOS-1.4.0.zip
• Version 1.4.0 (July 2013)
•
13年8月12⽇日星期⼀一
Drag Framework into Project 1.4
13年8月12⽇日星期⼀一
Drag Framework into Project 1.4
13年8月12⽇日星期⼀一
Drag GoogleMaps.bundle 1.4
13年8月12⽇日星期⼀一
Drag GoogleMaps.bundle 1.4
13年8月12⽇日星期⼀一
Google Maps SDK Framework
13年8月12⽇日星期⼀一
Configure Xcode Project - Library
原本就有, 其他請⼿手動加⼊入
1.1
13年8月12⽇日星期⼀一
Configure Xcode Project - Library
原本就有, 其他請⼿手動加⼊入
1.4
13年8月12⽇日星期⼀一
Setting
13年8月12⽇日星期⼀一
Create SingleView Application
UIView
13年8月12⽇日星期⼀一
Some code with Key
• AppDelegate.m
#import "AppDelegate.h"
#import <GoogleMaps/GoogleMaps.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[GMSServices provideAPIKey:@"key-Nk64"];
return YES;
}
13年8月12⽇日星期⼀一
Change Class
@interface ViewController ()
@property (weak, nonatomic)
IBOutlet GMSMapView *gmapView;
@end
13年8月12⽇日星期⼀一
Run it
13年8月12⽇日星期⼀一
User Location -View Controller
- (void)viewDidLoad
{
[super viewDidLoad];
self.gMapView.myLocationEnabled = YES;
self.gMapView.settings.myLocationButton = YES;
}
13年8月12⽇日星期⼀一
Run
13年8月12⽇日星期⼀一
Zoom Action
- (IBAction)moveToLocation:(id)sender {
CLLocationCoordinate2D userLocation = self.gMapView.myLocation.coordinate;
self.gMapView.camera =[GMSCameraPosition
cameraWithLatitude:userLocation.latitude longitude:userLocation.longitude zoom:
20];
}
1.4
13年8月12⽇日星期⼀一
Add mark
- (IBAction)addMark:(id)sender {
CLLocationCoordinate2D userLocation =
self.gMapView.myLocation.coordinate;
GMSMarker *school = [[GMSMarker alloc] init];
school.position = CLLocationCoordinate2DMake(userLocation.latitude
+0.001, userLocation.longitude+0.001);
school.snippet = @"School";
school.map = self.gMapView;
GMSMarker *hostpital = [[GMSMarker alloc] init];
hostpital.position =
CLLocationCoordinate2DMake(userLocation.latitude-0.001,
userLocation.longitude-0.001);
hostpital.snippet = @"Hospital";
hostpital.map = self.gMapView;
}
13年8月12⽇日星期⼀一
Add markers
13年8月12⽇日星期⼀一
StreetView
• GMSPanoramaView
• GMSPanoramaViewDelegate
13年8月12⽇日星期⼀一
StreetViewController.m
-(void) loadView{
[super loadView];
self.view = [GMSPanoramaView panoramaWithFrame:CGRectZero
nearCoordinate:self.nearCoordinate];
[(GMSPanoramaView *)self.view setDelegate:self];
}
- (void)panoramaView:(GMSPanoramaView *)panoramaView
didMoveCamera:(GMSPanoramaCamera *)camera {
NSLog(@"Camera: (%f,%f,%f)",
camera.orientation.heading, camera.orientation.pitch,
camera.zoom);
}
13年8月12⽇日星期⼀一
Tap info window of Marker
-(void) mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker
*)marker{
NSLog(@"%@", marker.snippet);
StreetViewController * streetViewController = [StreetViewController new];
streetViewController.nearCoordinate = CLLocationCoordinate2DMake(40.761388,
-73.978133);
[self presentViewController:streetViewController animated:YES completion:^{
;
}];
}
self.gMapView.delegate = self;
13年8月12⽇日星期⼀一
Run
13年8月12⽇日星期⼀一
Traffic Info
- (IBAction)showTraffic:(UISwitch *)sender {
self.gMapView.trafficEnabled = sender.on;
}
13年8月12⽇日星期⼀一

More Related Content

More from Michael Pan

Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android StudioMichael Pan
 
Eclipse and Genymotion
Eclipse and GenymotionEclipse and Genymotion
Eclipse and GenymotionMichael Pan
 
Strategy Pattern for Objective-C
Strategy Pattern for Objective-CStrategy Pattern for Objective-C
Strategy Pattern for Objective-CMichael Pan
 
Core data lightweight_migration
Core data lightweight_migrationCore data lightweight_migration
Core data lightweight_migrationMichael Pan
 
Homework2 play cards
Homework2 play cardsHomework2 play cards
Homework2 play cardsMichael Pan
 
Autorelease pool
Autorelease poolAutorelease pool
Autorelease poolMichael Pan
 
Objc under the_hood_2013
Objc under the_hood_2013Objc under the_hood_2013
Objc under the_hood_2013Michael Pan
 
Prototype by Xcode
Prototype by XcodePrototype by Xcode
Prototype by XcodeMichael Pan
 
Superstar dj pdf
Superstar dj pdfSuperstar dj pdf
Superstar dj pdfMichael Pan
 
比價撿便宜 Steven
比價撿便宜 Steven比價撿便宜 Steven
比價撿便宜 StevenMichael Pan
 
Appsgaga - iOS Game Developer
Appsgaga - iOS Game DeveloperAppsgaga - iOS Game Developer
Appsgaga - iOS Game DeveloperMichael Pan
 
GZFox Inc. Jacky
GZFox Inc. JackyGZFox Inc. Jacky
GZFox Inc. JackyMichael Pan
 
創投公司 hoku_20121017
創投公司 hoku_20121017創投公司 hoku_20121017
創投公司 hoku_20121017Michael Pan
 
Opening iOS App 開發者交流會
Opening iOS App 開發者交流會Opening iOS App 開發者交流會
Opening iOS App 開發者交流會Michael Pan
 

More from Michael Pan (20)

Activity
ActivityActivity
Activity
 
Shootting Game
Shootting GameShootting Game
Shootting Game
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
 
Eclipse and Genymotion
Eclipse and GenymotionEclipse and Genymotion
Eclipse and Genymotion
 
Note something
Note somethingNote something
Note something
 
Strategy Pattern for Objective-C
Strategy Pattern for Objective-CStrategy Pattern for Objective-C
Strategy Pattern for Objective-C
 
Core data lightweight_migration
Core data lightweight_migrationCore data lightweight_migration
Core data lightweight_migration
 
Homework2 play cards
Homework2 play cardsHomework2 play cards
Homework2 play cards
 
Autorelease pool
Autorelease poolAutorelease pool
Autorelease pool
 
Objc under the_hood_2013
Objc under the_hood_2013Objc under the_hood_2013
Objc under the_hood_2013
 
Prototype by Xcode
Prototype by XcodePrototype by Xcode
Prototype by Xcode
 
Dropbox sync
Dropbox syncDropbox sync
Dropbox sync
 
Nimbus
NimbusNimbus
Nimbus
 
Superstar dj pdf
Superstar dj pdfSuperstar dj pdf
Superstar dj pdf
 
ADB - Arthur
ADB - ArthurADB - Arthur
ADB - Arthur
 
比價撿便宜 Steven
比價撿便宜 Steven比價撿便宜 Steven
比價撿便宜 Steven
 
Appsgaga - iOS Game Developer
Appsgaga - iOS Game DeveloperAppsgaga - iOS Game Developer
Appsgaga - iOS Game Developer
 
GZFox Inc. Jacky
GZFox Inc. JackyGZFox Inc. Jacky
GZFox Inc. Jacky
 
創投公司 hoku_20121017
創投公司 hoku_20121017創投公司 hoku_20121017
創投公司 hoku_20121017
 
Opening iOS App 開發者交流會
Opening iOS App 開發者交流會Opening iOS App 開發者交流會
Opening iOS App 開發者交流會
 

Google maps SDK for iOS 1.4