2013-05-18 44 views
4

我更新了我的應用程序以使用Google Maps iOS SDK 1.3。除了GMSMarkers,一切似乎都行得通。它們要麼不出現,要麼出現錯誤的圖像。他們仍然對觸動作出反應,並且可以移動,但無形或腐敗。GMSMarker未顯示在1.3

這裏是添加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:

Map with Markers

我確實有一個lar地面疊加層的數量,以及去除疊加層使得標記重新出現,但是一些仍然具有不能正確顯示的奇怪圖像。它在1.2.2中工作正常,但不是1.3。

有沒有人有辦法讓標記工作?任何人都可以在GMSMarkers中看到這種行爲?

其他信息:該應用程序使用了cocos2d 2.0,導演加載地圖之前停止並添加GMSMapView中,如下所示:

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

我有在GMSMarker在谷歌地圖SDK IOS版本的類似問題:1.3.0.3430。我在它們之間繪製了GMSPolyline的點,所以我知道它們是,但沒有標記出現。也使用ARC。 – subv3rsion

+0

我嘗試使用新的1.3.1,它仍然缺少標記。 – gameburke

回答

0

它看起來像有對谷歌的一邊的錯誤。我剛剛停止使用我的CustomPlayerAnnotation或GMSMarker,並使用GMSGroundOverlay代替。那出現在地圖上。然後,我不是使用CustomPlayerAnnotation內置的類型,標記和座標對,而是依賴標題。

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)時,playerAnnotation疊加層將在疊加其他GMSGroundOverlay時切斷疊加層的底部。更改錨點固定了z繪圖。看起來1.4剛剛出來可能有z-順序固定,但1.4打破了我的其他東西,所以我現在堅持1.3.1。

0

請務必先初始化地圖對象視圖與相機位置,然後添加GMSMarker(s)。我正在創建我的標記,並將它們添加到地圖中。沒有出現,翻轉了邏輯,所有事情都按預期顯示。我的項目使用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_; 

}

+0

我確實實例化了地圖對象,然後是標記。通過翻轉邏輯我不知道你的意思。你是說你創建了GMSMarkers然後是地圖,然後添加了?我沒有那樣做。 – gameburke

+0

我使用相機位置在視圖中創建了地圖對象,將視圖設置爲地圖對象,然後添加了GMSMarkers。它們全都按預期顯示。測試1.3.0。 – subv3rsion

0

設置圖像邊緣之前,將其設置爲mapview

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