简体   繁体   English

在uimaps中添加google maps

[英]add google maps in uimaps

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 . 我用Google地图创建了一个Viewcontroller,但是我不需要将卡插入全尺寸的viewcontroller中,然后就得到了它(新视图中添加了GMSMapView类),但是我需要放置此地图标记。 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_; 问题-如果我添加一行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_; 您可以更改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. 您的mapView_将是主UIView的子视图,而不是占据整个屏幕。

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

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