简体   繁体   English

SKMaps iOS:平移地图时Pin会消失

[英]SKMaps iOS: Pin disappears when panning the Map

With the new Version (2.1.0) I get a problem. 使用新版本(2.1.0)我遇到了问题。 The Annotation disappears when scrolling the map. 滚动地图时,注释会消失。 In the demo project it works fine. 在演示项目中,它工作正常。 Also adding the frameworks again doesn't help. 再次添加框架也无济于事。

- (void)viewDidLoad {
    [super viewDidLoad];

    placeDetail = [[PlaceDetailViewController alloc] init];
    latitude = [placeDetail Latitude];
    longitude = [placeDetail Longitude];

    self.placeMapView = [[SKMapView alloc] init];
    self.placeMapView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
    self.placeMapView.delegate = self;
    self.placeMapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.placeMapView.settings.poiDisplayingOption = SKPOIDisplayingOptionNone;
    [self.view addSubview:self.placeMapView];

    //add a circle overlay
    for(int i=0;i<latitude.count;i++)
    {
        //set the map region
        SKCoordinateRegion region;
        region.center = CLLocationCoordinate2DMake([latitude[i] floatValue], [longitude[i] floatValue]);
        region.zoomLevel = 17;
        self.placeMapView.visibleRegion = region;

        SKAnnotation *mapAnnotation = [SKAnnotation annotation];
        mapAnnotation.identifier = i;
        mapAnnotation.minZoomLevel = 5;

        mapAnnotation.annotationType = SKAnnotationTypeRed;
        mapAnnotation.location = CLLocationCoordinate2DMake([latitude[i] floatValue], [longitude[i] floatValue]);

        [self.placeMapView addAnnotation:mapAnnotation];
    }
}

Annoation creation Annoation创作

-(void)mapView:(SKMapView *)mapView didSelectAnnotation:(SKAnnotation *)annotation {

    self.placeMapView.calloutView.titleLabel.text= placeDetail.Name;
    self.placeMapView.calloutView.titleLabel.font = [UIFont fontWithName:@"PTSans-Narrow" size:15];
    self.placeMapView.calloutView.subtitleLabel.text = @"";
    [self.placeMapView showCalloutForAnnotation:annotation withOffset:CGPointMake(0, 42) animated:YES];
    [self.placeMapView.calloutView.rightButton addTarget:self action:@selector(backToDetailView) forControlEvents:UIControlEventTouchUpInside];
}

I would appreciate your help. 我很感激你的帮助。

EDIT: I think I found the problem that causes this beahvior. 编辑:我想我发现了导致这种行为的问题。 In my app I have two kind of maps. 在我的应用程序中,我有两种地图。 One Mini Map and one large Map. 一张迷你地图和一张大地图。 But in two different views. 但在两个不同的观点。 When I deactivate the Mini Map it works. 当我停用Mini Map时,它可以工作。 SO I think it has to do with the loading of the SKMap framework. 所以我认为它与加载SKMap框架有关。 Currently the mini map function is called in view did load method. 目前迷你地图功能在视图中调用了load方法。 So you know what to do here? 所以你知道该怎么做吗?

It is a bug in the 2.1 and 2.2 versions of the SDK - it will be fixed in 2.3 (eta November 2014). 这是SDK的2.1和2.2版本中的一个错误 - 它将在2.3(2014年11月)中修复。

For 2.1/2.2 there is a workaround: having different id's for the annotations on the minimap and the big map. 对于2.1 / 2.2,有一种解决方法:对小地图和大地图上的注释使用不同的id。 For example you have N annotations on the minimap with ids 0..N-1, then the big map would have annotations with ids from N onward. 例如,你在小地图上有N个注释,其中有ids 0..N-1,那么大地图将有来自N向前的ids的注释。 So for M annotations on the big map you would have annotations with ids from N..M-1. 因此,对于大地图上的M注释,您可以使用N..M-1中的ID进行注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM