Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show window info when did tap cluster #63

Closed
thetay55 opened this issue Dec 10, 2016 · 11 comments
Closed

show window info when did tap cluster #63

thetay55 opened this issue Dec 10, 2016 · 11 comments

Comments

@thetay55
Copy link

I want to show window info when click cluster like when click maker, but how i don't know implement. Please, help me.

@mountainvat
Copy link
Contributor

This is actually a great request and should be on top of our list. Thanks.

@danielpietzsch
Copy link

FWIW: you can make markers that were added via the cluster library show their infoWindow. But it seems like you need to set the necessary marker properties before the marker gets rendered.

I was able to make cluster markers show the default info window, when I set their title or snippet properties in the willRenderMarker method of the GMUClusterRendererDelegate. E.g.:

- (void)renderer:(id<GMUClusterRenderer>)renderer willRenderMarker:(GMSMarker *)marker {
    if ([[[marker.userData class] description] isEqualToString:@"POIItem"]) {
        POIItem *poiItem = marker.userData;
        marker.title = poiItem.name;
        marker.icon = [UIImage imageNamed:@"custom_marker_icon"]; // it’s also handy to specify a custom marker icon for all markers
    }
}

Please note that this code might not work well for copy-pasting. I only wanted to give a hint on how to achieve showing default infoWindows. Adjust accordingly.
Of course you’d need to conform to the GMUClusterRendererDelegate protocol and specify the delegate when initialising the renderer. For example like so:

id<GMUClusterRenderer> renderer = [[GMUDefaultClusterRenderer alloc] initWithMapView:_mapView clusterIconGenerator:iconGenerator];

((GMUDefaultClusterRenderer *)renderer).delegate = self;

@mountainvat
Copy link
Contributor

Hi all,
we have committed a solution to this issue here cf73938 but since it's a breaking change we would like to release it in a 2.x.x version (pending other big features we wanted to get in). For now please see the solution in the commit and see if you can work around using it.

@matteodanelli
Copy link

Any update about this issue?
Is there any release date of version 2.x.x?

I am unable to do it using the approach explained before.

@mountainvat
Copy link
Contributor

We are in the process of pushing out 2.0.0 so stay tuned. Probably sometime next week if everything goes smoothly!

@hiteshwork
Copy link

@mountainvat any update on the issue as of now ?

@mountainvat
Copy link
Contributor

Hi @hiteshwork , 2.0.0 is out so please update your pod. The clusterManagerDelegate events (https://github.com/googlemaps/google-maps-ios-utils/blob/master/src/Clustering/GMUClusterManager.h#L40) now return a BOOL. Return NO to pass the event to the default handler (i.e showing info window).
Thanks.

@vburojevic
Copy link

vburojevic commented May 30, 2018

@mountainvat returning NO still doesn't show the info window when tapping on the marker in the cluster. What is the proper way to show the info window then?

@vburojevic
Copy link

Ok, in combination with willRenderMarker solution above and returning NO, I managed to show the info window.

@Prathapreddy26
Copy link

Prathapreddy26 commented Jan 10, 2019

Hello Guys,
delegate methods are not called when I was debug. Anyone know how to resolve this?

    id<GMUClusterAlgorithm> algorithm = [[GMUNonHierarchicalDistanceBasedAlgorithm alloc] init];
    id<GMUClusterRenderer> renderer = [[GMUDefaultClusterRenderer alloc] initWithMapView:self.mapView clusterIconGenerator:iconGenerator];
    ((GMUDefaultClusterRenderer *)renderer).delegate = self;
    self.clusterManager = [[GMUClusterManager alloc] initWithMap:self.mapView algorithm:algorithm renderer:renderer];
    [self.clusterManager cluster];

[self.clusterManager setDelegate:self mapDelegate:self];
[self.clusterRenderer setDelegate:self];

I added code like this.

@chocolatesoup
Copy link

chocolatesoup commented Jun 19, 2019

In case anyone is looking for the swift version of the renderer:

func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
     if let poiItem = marker.userData as? MapClusterItem {
            marker.title = poiItem.title
            marker.snippet = poiItem.snippet
            marker.icon = GMSMarker.markerImage(with: colorAccent)
     }
}

MapClusterItem is your class (in examples the name is POIItem) and colorAccent is a UIColor of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants