【发布时间】:2014-05-29 23:58:00
【问题描述】:
按照此处https://developers.google.com/maps/documentation/ios/starthttps://developers.google.com/maps/documentation/ios/start“入门”页面上的说明,我在我的应用中使用了 Google 地图。
让您启动并运行的代码示例(发布框架和 API 密钥等)如下所示。
我的问题是,作为一个 Xcode 菜鸟,我想知道如何将地图限制在我的视图控制器上的一个对象中,比如在 MKMapView 中。
我假设这条线
@implementation YourViewController {
GMSMapView *mapView_;
}
这段代码是以编程方式在整个视图控制器上创建地图的方式吗?
我怎样才能把它放在像 MKMapView 这样的东西中?
#import "YourViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@implementation YourViewController {
GMSMapView *mapView_;
}
- (void)viewDidLoad {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
}
@end
【问题讨论】:
-
您的问题到底是什么?目前的措辞尚不清楚。有什么事情没有按您的预期工作吗?如果不是,那是什么?
-
你的意思是作为一个不占据整个视图控制器视图的子视图?