GMSMarker没有在1.3中显示

我更新了我的应用以使用Google Maps iOS SDK 1.3。 除了GMSMarkers之外,一切似乎都有效。 它们要么不出现,要么出现错误的图像。 他们仍然会对触摸做出反应并且可以被移动,但是否则是隐形或腐败的。

以下是添加GMSMarkers的代码:

playerAnnotation = [[CustomPlayerAnnotation markerWithPosition:coord] retain]; [playerAnnotation setType:ANNOTATION_PLAYER]; [playerAnnotation setIcon:[UIImage imageNamed:@"Icon-72.png"]]; [playerAnnotation setGroundAnchor:ccp(.5f, .5f)]; [playerAnnotation setAnimated:NO]; [playerAnnotation setTappable:YES]; [playerAnnotation setTitle:@"Player"]; [playerAnnotation setMap:gameMapView]; GMSMarker* test = [[GMSMarker markerWithPosition:gameMapView.myLocation.coordinate] retain]; [test setIcon:[UIImage imageNamed:@"Icon-72.png"]]; [test setGroundAnchor:ccp(.5f, .5f)]; [test setAnimated:NO]; [test setTappable:YES]; [test setTitle:@"Player"]; [test setMap:gameMapView]; 

而CustomPlayerAnnotation只是一个带有一些额外变量的GMSMarker:

 @interface CustomPlayerAnnotation : GMSMarker { AnnotationType type; int tag; struct CoordinatePair coordinatePair; } 

使用CustomPlayerAnnotation映射并测试GMSMarker:

用标记映射

我确实有大量的地面覆盖,并删除覆盖层使标记重新出现,但有些仍然有奇怪的图像没有正确显示。 它在1.2.2中工作正常,但不是1.3。

有没有人有解决方法让Markers工作? 其他人在GMSMarkers中看到这种行为?

其他细节:该应用程序使用cocos2d 2.0,导演在加载地图之前停止,GMSMapView添加如下:

 UIWindow* window = [(ProjectFusionAppDelegate*)[[UIApplication sharedApplication] delegate] window]; [[[window subviews] objectAtIndex:0] addSubview:gameMapView]; 

确保首先使用摄像机位置在视图中实例化地图对象,然后添加GMSMarker。 我正在创建我的标记,并将它们添加到地图中。 什么都没有出现,翻转逻辑,一切都按预期显示。 我的项目使用ARC FYI。

 - (void)loadView { // Create a GMSCameraPosition that tells the map to display the // coordinates at zoom level 12. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:43.071482 longitude:-70.749856 zoom:12]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; self.view = mapView_; // Creates a marker in the center of the map, make sure the mapView_ is created, and // has the camera position set. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(43.071482, -70.749856); marker.title = @"Portsmouth"; marker.snippet = @"New Hampshire"; marker.map = mapView_; 

}

看起来谷歌方面存在一个漏洞。 我刚停止使用CustomPlayerAnnotation或GMSMarker,而是使用了GMSGroundOverlay。 这出现在地图上。 然后我没有使用我在CustomPlayerAnnotation中内置的type,tag和coordinatePair,而是依赖于标题。

 playerAnnotation = [[GMSGroundOverlay groundOverlayWithPosition:coord icon:[UIImage imageNamed:@"Down1.png"]] retain]; [playerAnnotation setZoomLevel:zoomLevel]; [playerAnnotation setAnchor:ccp(.5f, 1)]; [playerAnnotation setTitle:@"Player"]; [playerAnnotation setMap:gameMapView]; 

旁注:注意我必须setAnchor:ccp(.5f,1)。 当它设置为(.5f,.5f)时,当重叠其他GMSGroundOverlays时,playerAnnotation叠加将切断叠加层的底部。 更改锚点固定了z绘图。 看起来刚出来的1.4可能有z-ordering固定,但1.4打破了我的其他东西,所以我现在坚持1.3.1。

在将Image设置为mapview之前设置Image的边缘

 var icon : UIImage = UIImage(named: "userLocation")! icon = icon.imageWithAlignmentRectInsets(UIEdgeInsetsMake(-(icon.size.height/2), -(icon.size.width/2), 0, 0)) marker.icon = icon marker.map = GoogleMapView