相关疑难解决方法(0)

ViewForAnnotation未被调用

我正在尝试制作地图,在那里我可以看到我当前的位置,并查看街道的名称.

到目前为止,我可以在我的地图上放一个别针,但由于某种原因,我没有得到标注.我已经在我的viewForAnnotation方法中放了一个NSLog,但它没有被调用,所以我无法测试它.

有人能帮我吗?

-(void)lat:(float)lat lon:(float)lon
{
    CLLocationCoordinate2D location;
    location.latitude = lat;
    location.longitude = lon;
    NSLog(@"Latitude: %f, Longitude: %f",location.latitude, location.longitude);
    //One location is obtained.. just zoom to that location

    MKCoordinateRegion region;
    region.center=location;
    //Set Zoom level using Span
    MKCoordinateSpan span;
    span.latitudeDelta=.005f;
    span.longitudeDelta=.005f;
    region.span=span;
    [map setRegion:region animated:TRUE];

    //MKReverseGeocoder *geocoder=[[MKReverseGeocoder alloc] initWithCoordinate:location];
    //geocoder.delegate=self;
    //[geocoder start];
    if (cPlacemark != nil) {
        [map removeAnnotation:cPlacemark];
    }
    cPlacemark=[[CustomPlacemark alloc] initWithCoordinate:location];
    cPlacemark.title = mPlacemark.thoroughfare;
    cPlacemark.subtitle = mPlacemark.locality;
    [map addAnnotation:cPlacemark];
    [cPlacemark release];

    [mLocationManager stopUpdatingLocation];
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id …
Run Code Online (Sandbox Code Playgroud)

objective-c

19
推荐指数
4
解决办法
1万
查看次数

标签 统计

objective-c ×1