Git Product home page Git Product logo

Comments (11)

danielpietzsch avatar danielpietzsch commented on May 22, 2024 3

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;

from google-maps-ios-utils.

vburojevic avatar vburojevic commented on May 22, 2024 2

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

from google-maps-ios-utils.

chocolatesoup avatar chocolatesoup commented on May 22, 2024 2

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.

from google-maps-ios-utils.

mountainvat avatar mountainvat commented on May 22, 2024 1

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

from google-maps-ios-utils.

mountainvat avatar mountainvat commented on May 22, 2024

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

from google-maps-ios-utils.

mountainvat avatar mountainvat commented on May 22, 2024

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.

from google-maps-ios-utils.

matteodanelli avatar matteodanelli commented on May 22, 2024

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.

from google-maps-ios-utils.

hiteshwork avatar hiteshwork commented on May 22, 2024

@mountainvat any update on the issue as of now ?

from google-maps-ios-utils.

mountainvat avatar mountainvat commented on May 22, 2024

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.

from google-maps-ios-utils.

vburojevic avatar vburojevic commented on May 22, 2024

@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?

from google-maps-ios-utils.

Prathapreddy26 avatar Prathapreddy26 commented on May 22, 2024

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.

from google-maps-ios-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.