我有两张图片:默认标记状态为小图像,选择大图像。
点击标记后,我正在更改新状态的标记图标,但有时我会看到小图标放在大图标上。我认为它应该使用tracksViewChanges
属性进行更新,但事实并非如此。
你可以在图像上看到绿色标记,它有小图标。
我的代码很简单:
-(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
if (self.lastMarker) {
Car *lastCar = (Car*)self.lastMarker.userData;
self.lastMarker.icon = [lastCar.provider smallPinIcon];
}
Car *car = (Car*)marker.userData;
marker.tracksViewChanges = YES;
marker.icon = [car.provider bigPinIcon];
[UIView animateWithDuration:0.01 animations:^{
}
completion:^(BOOL finished) {
marker.tracksViewChanges = NO;
}];
self.lastMarker = marker;
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
bounds = [bounds includingCoordinate:self.userMarker.position];
bounds = [bounds includingCoordinate:marker.position];
GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds withEdgeInsets:UIEdgeInsetsMake(120, 60, 120, 60)];
[self.mapView animateWithCameraUpdate:update];
return YES;
}
方法smallPinIcon
和bigPinIcon
缓存实际图片。
这是Google Maps SDK错误或我做错了什么?