简体   繁体   English

如何将iOS版Google Map SDK实施到iPhone 4

[英]How to implement google map SDK for iOS to iPhone 4

I try to show custom map view using Google Maps SDK for iOS on iPhone 4 and iPhone 5 on simulator. 我尝试在iPhone 4和iOS 5的模拟器上使用iOS版Google Maps SDK显示自定义地图视图。

I create a UIViewController class for Google map Here is code 我为Google地图创建了UIViewController类这是代码

//GoogleMapViewController.h //GoogleMapViewController.h

#import <GoogleMaps/GoogleMaps.h>// for google map

@interface GoogleMapViewController : UIViewController{

    GMSMapView *mapView_;
}

//GoogleMapViewController.m //GoogleMapViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:13.909366 longitude:100.517446 zoom:5];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
}

and I load GoogleMapViewController to subview like this 我将GoogleMapViewController加载到这样的子视图

//RealTimeMonitoring.h //RealTimeMonitoring.h

@interface RealTimeMonitoring : UIViewController <UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *googleMapView;
@end

//RealTimeMonitoring.m //RealTimeMonitoring.m

#import "GoogleMapViewController.h"

- (void)viewDidLoad
{
[super viewDidLoad];

GoogleMapViewController *googleViwController = [[GoogleMapViewController alloc] initWithNibName:@"GoogleMapViewController" bundle:nil];
googleViwController.view.frame = self.googleMapView.bounds;
[self.googleMapView addSubview:googleViwController.view];
}

When I run it on iPhone 5 simulator it show correctly and the center of camera on map view look OK 当我在iPhone 5模拟器上运行它时,它可以正确显示,并且相机在地图视图上的中心看起来还可以

iPhone5成绩

But when I run it on iPhone simulator it seem to cut lower part a bit but the camera still center like it 但是当我在iPhone模拟器上运行它时,它似乎割下了一点,但相机仍然像这样居中

iPhone4成绩

When I coding game using Coco2d I recall that I must set the size or init view according to the device. 当我使用Coco2d编码游戏时,我记得必须根据设备设置大小或初始化视图。 But when I use interface builder I don't know how. 但是,当我使用界面生成器时,我不知道如何。

Question: How can I make it show like iPhone 5 on iPhone 4 问题:如何使它像iPhone 4上的iPhone 5一样显示

Ps. 附言 I still using macbook pro 13-inch Late 2011, Xcode 4.5.1 on OS X 10.7.5 and planing to update to mavericks soon 我仍在使用Macbook Pro 13英寸2011年末,在OS X 10.7.5上使用Xcode 4.5.1,并计划尽快更新为特立独行的

Thank. 谢谢。

Do you use storyboard with autolayout? 您是否使用自动布局的情节提要?

if so, go to the storyboard..select the view of the map and then go to 如果是这样,请转到情节提要。.选择地图视图,然后转到

Editor > pin > top space to superview Editor > pin > bottoms pace to superview Editor > pin > leading space to superview Editor > pin > trailing space to superview 编辑器>固定>超级视图的顶部空间编辑器>固定>超级视图的底部速度编辑器>固定>超级视图的前导空间编辑器>固定>超级视图的尾部空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM