【问题标题】:Blinking Custom Markers In Google maps iOS在 Google 地图 iOS 中闪烁自定义标记
【发布时间】:2017-01-24 09:56:52
【问题描述】:

我在 google maps iOS SDK 中放置了 6 个坐标相同的自定义标记。这些标记不断闪烁/切换。我根本不想要闪烁的动画。请帮帮我。

这是我的源代码。

-(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;
    }
}

【问题讨论】:

  • 显示你的代码!
  • 您使用的是哪个版本的 Google Maps SDK?
  • 请帮助我。我正在等待解决方案。
  • 您使用的是哪个吊舱?和pl。发布用于闪烁动画的图片(gif)。
  • 张贴你闪烁的图片 ..

标签: ios objective-c google-maps-markers google-maps-sdk-ios


【解决方案1】:

您必须为它们提供不同的 zIndex 属性。此属性定义哪个标记位于堆栈顶部。最高的数字在顶部。

对于您的代码,请在下面插入:

 marker.tappable = YES;

这行代码:

 marker.zIndex = (UInt32)i

【讨论】:

    【解决方案2】:

    您是否尝试过设置zIndex property of the markers?标记可能会闪烁,因为它们重叠并且没有明确的绘制顺序。

    【讨论】:

    • 我没有。你能给我一个源代码的例子吗?
    • 我已经尝试通过添加 zIndex 属性来解决这个闪烁问题。
    猜你喜欢
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 2019-11-14
    • 2015-03-28
    • 1970-01-01
    • 2015-08-28
    相关资源
    最近更新 更多