有什麼方法可以更改標記羣集中的默認標記圖標嗎?iOS中的標記羣集中的自定義標記圖標
這裏是我的代碼...
- (void)viewDidLoad {
[super viewDidLoad];
// Set up the cluster manager with a supplied icon generator and renderer.
id<GMUClusterAlgorithm> algorithm = [[GMUNonHierarchicalDistanceBasedAlgorithm alloc] init];
id<GMUClusterIconGenerator> iconGenerator = [[GMUDefaultClusterIconGenerator alloc] init];
id<GMUClusterRenderer> renderer = [[GMUDefaultClusterRenderer alloc] initWithMapView:googleMapView
clusterIconGenerator:iconGenerator];
clusterManager = [[GMUClusterManager alloc] initWithMap:googleMapView
algorithm:algorithm
renderer:renderer];
// Register self to listen to both GMUClusterManagerDelegate and
// GMSMapViewDelegate events.
[clusterManager setDelegate:self mapDelegate:self];
}
- (void)loadView {
// Create a GMSCameraPosition that tells the map to display the
_camera = [GMSCameraPosition cameraWithLatitude:29.3117
longitude:47.4818
zoom:8];
googleMapView = [GMSMapView mapWithFrame:CGRectZero camera:_camera];
googleMapView.myLocationEnabled = YES;
googleMapView.settings.compassButton = YES;
googleMapView.settings.myLocationButton = YES;
googleMapView.delegate = self;
self.view = googleMapView;
}
-(void)setLocation:(CLLocation *)location
{
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude);
[googleMapView animateToLocation:center];
[googleMapView animateToZoom:12];
NSMutableArray *array = [NSMutableArray arrayWithObjects:
@"29.0827,48.1363",
@"29.2679,47.9927",
@"29.348706, 48.092425",
@"29.340925, 48.088477",
@"29.324912, 48.089850",
@"29.330599, 47.990630",
@"29.300364, 47.960589",
@"29.271917, 47.918017",
@"29.3032,47.936", nil];
//remove all clusters before adding clusters
[clusterManager clearItems];
for (int i = 0; i < [array count]; i++)
{
center = CLLocationCoordinate2DMake ([[array[i] componentsSeparatedByString:@","][0] floatValue], [[array[i] componentsSeparatedByString:@","][1] floatValue]);
// Add items to the cluster manager.
NSString *name = nil;//[NSString stringWithFormat:@"Item %d", i];
id<GMUClusterItem> item =[[POIItem alloc] initWithPosition:center
name:name];
[clusterManager addItem:item];
}
// Call cluster() after items have been added
// to perform the clustering and rendering on map.
[clusterManager cluster];
}
請指引我...
如果你有一個版本> 1.1.0 [在這裏看到我的回答(https://stackoverflow.com/a/47560077/5792077) – Gerardo
如果你有一個版本> 1.1.0 [請看我的答案](https://stackoverflow.com/a/47560077/5792077) – Gerardo