2016-09-16 54 views
3

我已经在谷歌地图iOS SDK中以相同的坐标放置了6个自定义标记。这些标记持续闪烁/切换。我根本不想闪烁动画。请帮帮我。在谷歌地图上闪烁的自定义标记iOS

这是我的源代码。

-(void)loadPlacesInMapWithIndex:(int)index{ 

    for (int i = 0; i < [[[SearchManager sharedInstance]searchedStallArray] count]; i++) { 
     Stall *stall = [[[SearchManager sharedInstance]searchedStallArray] objectAtIndex:i]; 

     // Creates a marker in the center of the map. 
     GMSMarker *marker = [[GMSMarker alloc] init]; 
     marker.position = CLLocationCoordinate2DMake([stall.stallLatitude doubleValue],[stall.stallLongitude doubleValue]); 
     marker.infoWindowAnchor = CGPointMake(0.44f, -0.07f); 
     marker.userData = stall; 
     marker.tappable = YES; 
     self.infoView = [[[NSBundle mainBundle]loadNibNamed:@"StallInfoWindow" owner:self options:nil] objectAtIndex:0]; 

     marker.iconView = self.infoView; 
     if (index == i) { 
      [self.infoView.stallPinImageView setImage:[UIImage imageNamed:@"RateLabel.png"]]; 
      [self.infoView.stallPriceLabel setTextColor:[UIColor whiteColor]]; 

      CGFloat currentZoom = self.stallsMapView.camera.zoom; 
      [CATransaction begin]; 
      [CATransaction setValue:[NSNumber numberWithFloat: 0.5f] forKey:kCATransactionAnimationDuration]; 
      [self.stallsMapView animateToCameraPosition:[GMSCameraPosition 
                  cameraWithLatitude:[stall.stallLatitude doubleValue] 
                  longitude:[stall.stallLongitude doubleValue] 
                  zoom:currentZoom]]; 
      [CATransaction setCompletionBlock:^{ 
      }]; 
      [CATransaction commit]; 

     }else{ 
      [self.infoView.stallPinImageView setImage:[UIImage imageNamed:@"horse.png"]]; 
      [self.infoView.stallPriceLabel setTextColor:[UIColor redColor]]; 
     } 

     self.infoView.stallPriceLabel.text = [NSString stringWithFormat:@"$%@",stall.stallPrice]; 

     marker.map = self.stallsMapView; 
    } 
} 
+0

显示你的代码! – user3207158

+0

您使用的是哪个版本的Google Maps SDK? –

+0

有些身体请帮助我。我在等待解决方案。 –

回答

0

您是否尝试过设置zIndex property of the markers?可能标记会因为重叠而眨眼,并且没有明确的绘图顺序。

+0

我没有。你能否给我一个源代码的例子。 –

+0

我试过这个闪烁的问题,通过添加zIndex属性来解决。 –

5

您必须提供差异zIndex财产。该属性定义哪个标记位于堆栈的顶部。最高的数字是最高的。

为您的代码,插入下:

marker.tappable = YES; 

这行代码:

marker.zIndex = (UInt32)i 
+0

谢谢@B2D它正在帮助我。 –