2013-11-27 137 views
0

所以我有一个谷歌地图在我的一个主视图的小视图中,我试图让徽章显示一个位置,如在他们的示例中显示的谷歌地图..但经过多年试图让地图显示在一个可调整大小的视图内(所以我可以在另一个视图中显示它),我做过的方式似乎没有添加徽章的方式。谷歌地图iOS SDK - 添加徽章

这是我到目前为止的代码:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                 longitude:151.20 
                  zoom:6]; 
// Create marker 
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(-33.86, 151.20); 
GMSMarker *marker = [GMSMarker markerWithPosition:position]; 
marker.title = @"Hello World"; 


self.map.camera = camera; 

self.map是(在.h文件):

@property (weak, nonatomic) IBOutlet GMSMapView *map; 

这是谷歌的例子:

// Google map 
// 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_; 

但我似乎无法将两者结合起来

回答

0

对于任何一个与类似的问题挣扎: 这是我如何解决使用自定义视图与谷歌地图+徽章

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6]; 
// set camera location to Novi Sad, Serbia :-) 

[self.mymap setCamera:camera];  // set the camera to map 


// 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 = mymap;