MapView设置位置

时间:2012-06-02 11:03:41

标签: ios mapkit

任何人都可以帮我解决一个mapView应用程序的问题,该应用程序只显示默认位置而不是我指定的具体位置。我的代码如下。我正在学习Xcode,所以可能犯了一个小学生的错误: -

.H

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>


@interface RavenMapViewController : UIViewController <MKMapViewDelegate> {
MKMapView *mapView;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;

-(void) goLocation;
@end

.M

#import "RavenMapViewController.h"


@implementation RavenMapViewController

@synthesize mapView;


-(void) goLocation 

{

    MKCoordinateRegion newRegion;
    newRegion.center.latitude = 39.278112;
    newRegion.center.longitude = -76.622772;
    newRegion.span.latitudeDelta = 0.008388;
    newRegion.span.longitudeDelta = 0.016243;

    [self.mapView setRegion:newRegion animated:YES];

}

- (void)viewDidLoad 
{
    [self goLocation];
}

- (void)viewDidUnload 

{


}

@end

0 个答案:

没有答案