我有代码在Google地图上添加单个图钉。这项工作完全。 但是当我添加第二个引脚时,它会覆盖第一个引脚。 这是我在地图上添加单个图钉的代码。
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"];
答案 0 :(得分: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_;
}
这项工作对我而言。
答案 1 :(得分: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;
}