gpt4 book ai didi

ios - 在 Google map iOS 中闪烁自定义标记

转载 作者:可可西里 更新时间:2023-11-01 04:17:07 25 4
gpt4 key购买 nike

我在谷歌地图 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;
}
}

最佳答案

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

对于您的代码,请插入:

 marker.tappable = YES;

这行代码:

 marker.zIndex = (UInt32)i

关于ios - 在 Google map iOS 中闪烁自定义标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39526942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com