在uimaps中添加谷歌地图 [英] add google maps in uimaps

查看:147
本文介绍了在uimaps中添加谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Google地图创建了一个视图控制器,但是我没有必要在全尺寸视图控制器中插入这张卡片,并且我得到了它(我添加了一个类GMSMapView的新视图),但我需要放置这个地图标记。我的标记示例

  CLLocationCoordinate2D position2 = CLLocationCoordinate2DMake(59.957069,30.323013); 
GMSMarker * london2 = [GMSMarker markerWithPosition:position2];
london2.title = @我的办公室;
london2.snippet = @description;
london2.map = mapView_;

这是我的代码

   - (void)viewDidLoad {
[super viewDidLoad];
self.mapView_.mapType = kGMSTypeNormal;
self.mapView_.settings.compassButton = YES;
self.mapView_.settings.myLocationButton = YES;
self.mapView_.delegate = self;
[GMSServices provideAPIKey:@###];
GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:1];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

mapView_.myLocationEnabled = YES;
mapView_.settings.compassButton = YES;
mapView_.settings.myLocationButton = YES;
//self.view = mapView_;

GMSMarker * london2 = [GMSMarker markerWithPosition:position2];
london2.title = @我的办公室;
london2.snippet = @description;
london2.map = mapView_;

问题 - 如果我添加一行self.view = mapView_;这张卡片在整个屏幕上用正确的标记反射给我,如果我移除它,它会反射出没有标记,但是我想要的大小 - 如何修复它(制作所需大小和标记的地图)

解决方案

您可以更改您的 self.view = mapView _;

$ b $
$ b

  mapView.frame = CGRectMake(YOUR_MAP_X,YOUR_MAP_Y,YOUR_MAP_WIDTH,YOUR_MAP_HEIGHT ); 
[self.view addSubview:mapView_];

您的mapView_将成为您的主UIView的子视图,而不是占用整个屏幕。


I created a viewcontroller with Google maps , but I have no need to insert the card in full size viewcontroller, and I got it ( the new view I added a class GMSMapView) but I need to put this map markers . Example of my marker

    CLLocationCoordinate2D position2 = CLLocationCoordinate2DMake(59.957069, 30.323013);
GMSMarker *london2 = [GMSMarker markerWithPosition:position2];
london2.title = @"my office";
london2.snippet = @"description";
london2.map = mapView_;

This is my code

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mapView_.mapType = kGMSTypeNormal;
 self.mapView_.settings.compassButton = YES;
 self.mapView_.settings.myLocationButton = YES;
  self.mapView_.delegate = self;
 [GMSServices provideAPIKey:@"###"];
   GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:1];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

    mapView_.myLocationEnabled = YES;
    mapView_.settings.compassButton = YES;
    mapView_.settings.myLocationButton = YES;
    //self.view = mapView_;

GMSMarker *london2 = [GMSMarker markerWithPosition:position2];
london2.title = @"my office";
london2.snippet = @"description";
london2.map = mapView_;

Question - if I add a line self.view = mapView_; the card is reflected on the whole screen with the right markers to me , if I remove , it is reflected without markers , but my desired size - how to fix it ( make a map of the desired size and markers )

解决方案

You can change your self.view = mapView_;

to the following code:

mapView.frame = CGRectMake(YOUR_MAP_X, YOUR_MAP_Y, YOUR_MAP_WIDTH, YOUR_MAP_HEIGHT);
[self.view addSubview:mapView_];

Your mapView_ will be a subview of your main UIView, instead of occupying the entire screen.

这篇关于在uimaps中添加谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆