2014-03-04 4 views
1

Google지도에 단일 핀을 추가하는 코드가 있습니다. 그리고 이것은 완전히 작동합니다. 하지만 두 번째 핀을 추가하면 첫 번째 핀으로 대체됩니다. 지도에 단일 핀을 추가하는 코드입니다.ios 앱에서 여러 핀을 추가하는 방법

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude1 longitude:longitude1 zoom:18]; 

mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapView_.myLocationEnabled = YES; 

self.view = mapView_; 
GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(latitude1, longitude1); 
marker.title = @"Ahmedabad"; 
marker.snippet = @"India"; 
marker.map = mapView_; 
marker.icon = [UIImage imageNamed:@"m1.png"]; 

답변

4
self.view = mapView_;  
for(int i=0;i<[array count];i++) 
{  
    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.animated=YES; 
    marker.position = CLLocationCoordinate2DMake(latitude,longitude); 
    marker.title = @"name"; 
    marker.snippet = @"snippet"; 
    marker.map = mapView_; 
} 

나를 위해이 작품.

0
self.view = self.googleMapView;  
for(int i=0;i<[markerArray count];i++) 
{ 
    CLLocationCoordinate2D location = [markerArray objectAtIndex:i]; 
    GMSMarker *marker = [[GMSMarker alloc] init]; 
    marker.animated=YES; 
    marker.position = CLLocationCoordinate2DMake(location.latitude,location.longitude); 
    marker.title = @"name"; 
    marker.snippet = @"snippet"; 
    marker.map = self.googleMapView; 
} 
+0

설명이 좋을 것 – krisdyson

관련 문제