googlemap上未显示注释

时间:2016-05-03 09:41:43

标签: ios objective-c xcode google-maps google-maps-api-3

注释没有显示在地图上。原因可能是什么?请帮助。我在地图上看不到任何Pin或Annotations,它显示的是葡萄牙,西班牙等地区。

addressArray = dictionary[@"data"][@"centers"];
NSArray *latitude =[dictionary[@"data"][@"centers"]valueForKey:@"lat"];
NSArray *longitude=[dictionary[@"data"][@"centers"]valueForKey:@"lng"];
NSString *cname=[dictionary[@"data"][@"centers"]valueForKey:@"category_name"];
loaderView.hidden = true;
NSLog(@"%@",latitude);
NSLog(@"%@",longitude);
NSLog(@"%@",cname);
UIImage *pinImage = [UIImage imageNamed:@"map_gym"];
GMSMarker *mark=[[GMSMarker alloc]init];
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[latitude objectAtIndex:0] doubleValue] ,[[longitude objectAtIndex:0] doubleValue]);
NSLog(@"%@",[latitude objectAtIndex:0]);
NSLog(@"%@",[longitude objectAtIndex:0]);
mark.position =coord;
mark.title=cname;
mark.icon=pinImage;
mark.infoWindowAnchor = CGPointMake(0.5, 0.25);
mark.groundAnchor = CGPointMake(0.5, 1.0);
mark.map=_mapView;

1 个答案:

答案 0 :(得分:0)

我认为标记的坐标没有正确实现。请查看Google's Document中的代码示例。

CLLocationCoordinate2D position = CLLocationCoordinate2DMake(10, 10);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = @"Hello World";
marker.map = mapView_;

尝试将代码调整为此。

E.g。

CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[latitude objectAtIndex:0] doubleValue] ,[[longitude objectAtIndex:0] doubleValue]);
GMSMarker *marker = [GMSMarker markerWithPosition:coord];
marker.title = @"Hello World";
    marker.map = mapView_;