标记图标图像复制

时间:2017-06-22 20:29:56

标签: ios google-maps-sdk-ios

我有两张图片:默认标记状态为小图像,选择大图像。

点击标记后,我正在更改新状态的标记图标,但有时我会看到小图标放在大图标上。我认为它应该使用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;

}

方法smallPinIconbigPinIcon缓存实际图片。

这是Google Maps SDK错误或我做错了什么?

map with marker

0 个答案:

没有答案