0

我正在开发和 iphone 应用程序,我正在使用 Mappy SDK IOS。

我到达是为了显示地图并显示我当前的位置。但我在地图上添加一些标记时遇到问题。

我有一个 NSArray,其中包含一些具有经度和纬度属性的对象。我显示标记的代码是:

    - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //initialisation mot de passe + user
    [MPInit initialisation:MAPPY_API_KEY];
    [RMMapView class];
    
    //show user location
    self.mapView.showsUserLocation = NO;
    self.mapView.showPoi = YES;
    
    //set delegate
    self.mapView.delegate = self;
    
    MPMarkerManager *markerManager = [self.mapView markerManager];
    MPMarkerCategory * category = [markerManager getCategory:@"storeLocations"];
    
    //remove old elements   
    [category.dataSource removeAllElements];
    
    //add markers on map
    for(int i=0; i<self.arrayStores.count; i++) {
        NSLog(@"add store %d on the map", i);
        NSDictionary* currentStore = [self.arrayStores objectAtIndex:i];
        float latitude  = [[currentStore objectForKey:@"latitude"] floatValue];
        float longitude = [[currentStore objectForKey:@"longitude"] floatValue];
        
        CLLocationCoordinate2D locationStore = CLLocationCoordinate2DMake(latitude, longitude);

        //create a new POI object with location 
        MPPoi * poi = [[MPPoi alloc] initWithUId:[currentStore objectForKey:@"title"] withLocation:locationStore];
        [category.dataSource addElement:poi];
        self.mapView.centerCoordinate = locationStore;
        [poi release];
    }
    
    //category settings 
    category.markerColor = [UIColor greenColor];
    //[category setOptimalZoom:YES];//set the zoom to be optimal : show all poi in the category
    [category setHideLabelOnTheFirstShow:NO];
    [category setAnimateAtFirstShow:YES];
    
}

这是控制台上显示的日志:

2012-06-14 17:01:18.359 Koutoubia[609:607] MappyKit version:1.40
2012-06-14 17:01:18.672 Koutoubia[609:607] add store 0 on the map

我做错了什么??因为不显示标记

在文档上添加标记的文档是:

//add a marker on map
   MPMarkerManager *markerManager = [viewController.mapView markerManager];
   MPMarkerCategory * category = [markerManager getCategory:HMP_LOC_CATEGORY];
   //remove old elements    
   [category.dataSource removeAllElements];
   //create a new POI object with location  
   MPPoi * poi = [[MPPoi alloc] initWithUId:locationData.address withLocation:findLocation];
   [category.dataSource addElement:poi];
   [poi release];

文档的链接在这里

有任何想法吗 ??提前致谢

4

1 回答 1

0

我已经建立了解决方案,问题是我忘记初始化MPMarkerCategory并将其添加到markerManager方法中viewDidLoad

//Marker initialization
    MPMarkerManager *markerManager = [self.mapView markerManager];
    //add a new category with green default color
    [markerManager addCategory:STORE_LOC_CATEGORY withColor:[UIColor greenColor]];
于 2012-06-15T09:15:44.547 回答