-1

ユーザーがボタンを押したときにユーザーの現在の場所に注釈を付けたいのですが、コアの場所で試しましたが、互換性がありません。

これは例です:

-(IBAction)anotation:(sender){


    CLLocationCoordinate2d *coor;

    MKUserlocation *ul;

    coor.latitude = **ul.location.latitude** //or something like that;

    ...
    ...


}

手伝って頂けますか?

4

1 に答える 1

0

ボタンのクリックに対して、この Action zoomToCurrentLocation を試してください。getGotFix は、このコールバックによって設定されたフラグをチェックします

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

これがIBActionコードです(SOに重複があると確信しています)

- (IBAction)zoomToCurrentLocation:(id)sender 
{

MKCoordinateRegion region;

if ([utils getGotFix] == YES)
{
    region.center = self.mapView.userLocation.coordinate; 

    MKCoordinateSpan span; 
    span.latitudeDelta  = 2; // Change these values to change the zoom 1 degree = 69 miles
    span.longitudeDelta = 2; 
    region.span = span;

    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(region.center, 2*METERS_PER_MILE, 2*METERS_PER_MILE);
    MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion]; 
    [mapView setRegion:adjustedRegion animated:YES];  
}
else 
{   // We dont yet have a user location fix so inform user
    UIAlertView * timeoutAlert = [[UIAlertView alloc] initWithTitle:@"No location fix" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [timeoutAlert show];
}

}

于 2013-01-10T16:14:56.357 に答える