GMSMarker没有在1.3中显示 [英] GMSMarker not showing in 1.3

查看:150
本文介绍了GMSMarker没有在1.3中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I updated my app to use Google Maps iOS SDK 1.3. Everything seems to work except for the GMSMarkers. They either don't appear or appear with the wrong image. They still respond to touches and can be moved, but are otherwise invisible or corrupt.

以下是添加GMSMarkers的代码:

Here is the code for adding 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:

And CustomPlayerAnnotation is simply a GMSMarker with some extra variables:

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

使用CustomPlayerAnnotation映射并测试GMSMarker:

Map with CustomPlayerAnnotation and test GMSMarker:

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

I do have a large amount of ground overlays, and removing the overlays made a marker reappear, but some still have odd images that aren't showing up properly. It works fine in 1.2.2, but not 1.3.

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

Does anyone have a workaround for getting Markers working? Anyone else see this behavior in GMSMarkers?

其他细节:该应用程序使用的是cocos2d 2.0,导演在加载地图之前停止,GMSMapView按如下方式添加: / p>

Other Details: The app is using cocos2d 2.0, the director is stopped before loading the map and the GMSMapView is added as follows:

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


推荐答案

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

It looks like there is a bug on Google's side. I just stopped using my CustomPlayerAnnotation or GMSMarker, and used a GMSGroundOverlay instead. That showed up on the map. Then instead of using the type, tag, and coordinatePair I built into CustomPlayerAnnotation, I just relied on the title.

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。

Side note: notice that I had to setAnchor:ccp(.5f, 1). When it was set to (.5f, .5f) the playerAnnotation overlay would cut off the bottom of the overlay when overlapping other GMSGroundOverlays. Changing the Anchor fixed the z drawing. It looks like 1.4 that just came out may have z-ordering fixed, but 1.4 broke something else on mine so I'll stick with 1.3.1 for now.

这篇关于GMSMarker没有在1.3中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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