0

我正在尝试显示地图工具包,并且正在执行以下操作: MapViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <QuartzCore/QuartzCore.h>
@interface SiteViewController : UIViewController <MKMapViewDelegate>

@property (assign, nonatomic)       MKCoordinateRegion  region;
@property (strong, nonatomic)       IBOutlet MKMapView  *googleMap;

@end

MapViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Set propertiesfor the mapView
    self.region.center.latitude         =   43.62862 ; // expression is not assigned
    self.region.center.longitude        =   -79.331245;// expression is not assigned
    self.region.span.longitudeDelta     =   0.01f;     // expression is not assigned
    self.region.span.longitudeDelta     =   0.01f;     // expression is not assigned
    [self.googleMap setMapType:MKMapTypeStandard];
    [self.googleMap setZoomEnabled:YES];
    [self.googleMap setScrollEnabled:YES];
    [self.googleMap setRegion:self.region animated:YES];


    MKPointAnnotation *pin = [[MKPointAnnotation alloc] init];
    pin.coordinate  = region.center;
    [self.googleMap addAnnotation:pin];
}

我正进入(状态

表达式未赋值

我不明白。有人可以解释一下,让我摆脱这个麻烦。

4

1 回答 1

0

您需要通过 region 属性或方法设置地图视图区域- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated;

尝试这个:

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(43.62862, -79.331245);

[self.mapView setRegion:MKCoordinateRegionMake(coordinate, MKCoordinateSpanMake(0.01f, 0.01f))];
于 2013-01-18T21:03:22.383 回答