More Related Content
More from Michael Pan (20)
Google maps SDK for iOS 1.4
- 4. Get Google Map API Key
• 從 Google APIs Console 產⽣生 API 專案.
13年8月12⽇日星期⼀一
- 20. 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⽇日星期⼀一
- 23. User Location -View Controller
- (void)viewDidLoad
{
[super viewDidLoad];
self.gMapView.myLocationEnabled = YES;
self.gMapView.settings.myLocationButton = YES;
}
13年8月12⽇日星期⼀一
- 25. 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⽇日星期⼀一
- 26. 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⽇日星期⼀一
- 29. 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⽇日星期⼀一
- 30. 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⽇日星期⼀一