相关疑难解决方法(0)

除了用户位置注释之外,如何从MKMapView中删除所有注释?

removeAnnotations用来删除我的注释,mapView但同样删除用户位置ann.我该如何防止这种情况,或者如何让用户回来查看?

NSArray *annotationsOnMap = mapView.annotations;
        [mapView removeAnnotations:annotationsOnMap];
Run Code Online (Sandbox Code Playgroud)

xcode mkmapview mkannotation userlocation ios

40
推荐指数
3
解决办法
3万
查看次数

添加另一个时如何删除以前的注释引脚?

我有一个UITableView,每个单元格都包含一个Map按钮.当我点击每个按钮时,会显示地图视图并添加相应的注释引脚.

点击每个地图按钮时会调用此代码,

    double tempLatitude  = [[[myDict objectForKey:key] objectAtIndex:15] doubleValue];
    double tempLongitude = [[[myDict objectForKey:key] objectAtIndex:16] doubleValue];
                                                  // key is the cell index.

         //--** Setting the Latitude and Longitude 
         CLLocationCoordinate2D myCoordinate;

         myCoordinate.latitude  = tempLatitude;
         myCoordinate.longitude = tempLongitude;

         MyMapAnnotation *MyAnnotation = [[[MyMapAnnotation alloc] initWithCoordinate:myCoordinate addressDictionary:nil]autorelease];
         MyAnnotation.title            = [[myDict objectForKey:key] objectAtIndex:1];
         MyAnnotation.subtitle         = [NSString  stringWithFormat:@"%f %f", MyAnnotation.coordinate.latitude, MyAnnotation.coordinate.longitude];
Run Code Online (Sandbox Code Playgroud)

这是MyMapAnnotation的代码,

    @synthesize coordinate = theCoordinate;
    @synthesize title = theTitleAnnotation;
    @synthesize subtitle = theSubTitleAnnotation;



    - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary 
    {

      if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
      { …
Run Code Online (Sandbox Code Playgroud)

iphone annotations objective-c mapkit mkmapview

3
推荐指数
1
解决办法
2550
查看次数