简体   繁体   中英

show multiple maker in google map objective c

I need to show multiple maker in google map objective c

GMSMapView *map2 = [GMSMapView mapWithFrame:CGRectMake(0, 60, 450, 550) camera:camera];
[self.view addSubview:map2];
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"33.588589,-7.606035",@"33.575585,-7.608526", nil];

for (int i = 0; i < [array count]; i++)
{        GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake([[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:0] floatValue],[[[[array objectAtIndex:0]  componentsSeparatedByString:@","] objectAtIndex:1] floatValue]);
    marker.title = etatMap;
    marker.icon=[UIImage imageNamed:@"iconmap.png"];
    marker.snippet = vitesseMap;
    marker.map = map2;
    [array removeObjectAtIndex:0];

}

try this

for (int i = 0; i < [array count]; i++)
{      
    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake([[[[array objectAtIndex:i]  componentsSeparatedByString:@","] objectAtIndex:0] floatValue],[[[[array objectAtIndex:i]  componentsSeparatedByString:@","] objectAtIndex:1] floatValue]);
    marker.title = etatMap;
    marker.icon=[UIImage imageNamed:@"iconmap.png"];
    marker.snippet = vitesseMap;
    marker.map = map2;
}

You can learn more about google map from below link http://courseware.codeschool.com/googlemapsios/Exploring-Google-Maps-For-iOS-FULL.pdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM