1

目标 c 的新手,我将 ArcGIS 用于地图部分。我有一个mapViewDidLoad没有调用/加载该方法的问题。这是代码的一部分:

.h 文件

@interface ViewController : UIViewController<AGSMapViewLayerDelegate, AGSMapViewTouchDelegate, AGSMapViewCalloutDelegate>{
AGSMapView *_mapView;
AppDelegate *appDelegate;
...
}

.m 文件

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.activityView startAnimating];
    self.mapView.touchDelegate = self;
    self.mapView.calloutDelegate = self;
    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    ...
}

- (void)mapViewDidLoad:(AGSMapView *)mapView {

    AGSEnvelope *envelope = [[AGSEnvelope alloc]initWithXmin:29757.610204117
                                                    ymin:40055.0379682464
                                                    xmax:29884.6992302249
                                                    ymax:40236.6028660071
                                        spatialReference:self.mapView.spatialReference];
    [self.mapView zoomToEnvelope:envelope animated:YES];

    self.mapView.callout.width = 195.0f;
    self.mapView.callout.accessoryButtonHidden = YES;

    [self.mapView.gps start];
    [self.mapView centerAtPoint:self.mapView.gps.currentPoint animated:YES];   
    NSLog(@"Location : %@", self.mapView.gps.currentPoint);

    [self.activityView stopAnimating];
    self.activityView.hidden = YES;

}

我的代码有什么问题,为什么我不加载该mapViewDidLoad方法。提前致谢。

4

2 回答 2

0

只需self.mapView.delegate = self;添加viewDidLoad

于 2012-08-06T07:37:10.850 回答
0

确保通过右键单击mapview连接mapviewdelegate,然后分配委托.. 在此处输入图像描述

或添加[self.mapview setDelegate:self];

在您的情况下,“AGSMapView”mapViewDidLoad:在将第一层添加到地图后调用 AGSMapViewLayerDelegate 上的方法。此时,该组件功能齐全,您可以在 http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/reference/interface_a_g_s_map_view.html中找到对它的引用

使 self.mapview.layerDelegate = self;

于 2012-08-06T07:38:51.363 回答