如何在iPhone的谷歌地图中获得每个pin的描述

如何在iPhone的谷歌地图中获得每个pin的描述,iphone,annotations,mkmapview,Iphone,Annotations,Mkmapview,我对MKPointAnnotation有问题。我想像这样创建我的iPhone应用程序: 在谷歌地图中显示pin码 显示每个pin上的描述,从NSMutableArray中提取该描述 所以,我的问题是,如何在每个pin上显示描述 这是我的代码: NSMutableArray *points = [[NSMutableArray alloc] init]; for(int i=0; i < [dataTable count]; i++) { MKPointAnnotation *po

我对
MKPointAnnotation
有问题。我想像这样创建我的iPhone应用程序:

  • 在谷歌地图中显示pin码
  • 显示每个pin上的描述,从
    NSMutableArray
    中提取该描述
  • 所以,我的问题是,如何在每个pin上显示描述

    这是我的代码:

     NSMutableArray *points = [[NSMutableArray alloc] init];
     for(int i=0; i < [dataTable count]; i++) {
       MKPointAnnotation *point =[[MKPointAnnotation alloc] init];
       CLLocationCoordinate2D coordinate;
       coordinate.latitude = [[[dataTable objectAtIndex:i] objectForKey:@"latitude"] floatValue];
       coordinate.longitude = [[[dataTable objectAtIndex:i] objectForKey:@"longitude"] floatValue];
       [point setCoordinate:coordinate];
       [point setTitle:[[dataTable objectAtIndex:i] objectForKey:@"name"]]; //-- name of pin
       [points addObject:point];
     }
     [map addAnnotations:points];
    
    NSMutableArray*points=[[NSMutableArray alloc]init];
    对于(int i=0;i<[数据表计数];i++){
    MKPointAnnotation*point=[[MKPointAnnotation alloc]init];
    CLLocationCoordinate2D坐标;
    coordinate.latitude=[[dataTable objectAtIndex:i]objectForKey:@“latitude”]floatValue];
    coordinate.longitude=[[dataTable objectAtIndex:i]objectForKey:@“经度”]floatValue];
    [点设置坐标:坐标];
    [point setTitle:[[dataTable objectAtIndex:i]objectForKey:@“name”]];/--pin的名称
    [点添加对象:点];
    }
    [地图注释:点];
    
    我会在自己的类中采用MKAnnotation协议,并简单地重写

     - (NSString) title
    
    实施

     - (CLLocationCoordinate2D) coordinate {
        CLLocationCoordinate2D theCoordinate;
        theCoordinate.latitude = self.latitude;
        theCoordinate.longitude = self.longitude;
        return theCoordinate; 
     }
    
    我的类还有一个初始化器,它获取它所需的所有数据(来自您提到的数组)

    迭代时,我会创建自己的对象,然后将它们添加到注释集合中

    干杯

    - (id) initWithTitle:(NSString *)title_ andLatitude:(CLLocationDegrees)latitude_ andLongitude:(CLLocationDegrees)longitude_;