-1

I have a cluster marker in the method markerInfoWindow (https://developers.google.com/maps/documentation/ios-sdk/reference/protocol_g_m_s_map_view_delegate-p)

When the marker is selected and the marker title says "Coming soon", the opacity of the marker becomes 0.5

image here My issue is that i want also the opacity of this marker to be 0.5 when is not selected, not only in selection.But i can't find a public method for that.Can anyone help?

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
PanosG
  • 1
  • 2

1 Answers1

1

You need to create a custom class of which is inherited GMUClusterItem like

/// Cluster Item
class EVPOIItem : GMUClusterItem{
    init(icon : UIImage) {
        self.icon = icon
    }
}

after that, with the help of GMUClusterRendererDelegate you can change the icon of the marker and other updates like

extension ViewController : GMUClusterRendererDelegate{

func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
    if (marker.userData! is EVPOIItem) {
        let customClusterItem = (marker.userData! as! EVPOIItem)
        marker.icon = customClusterItem.icon
    }
}

let me know if you have any doubts.

Mayur Karmur
  • 2,119
  • 14
  • 35
  • I have created the POitem class and it's already works.The problem is that func mapView(_ mapView: GMSMarker, markerInfoWindow marker: GMSMarker) -> UIView { is only for selected marker...i need a func like didShowMarker or somthing like that.. so i can call the marker.icon here and to make the opacity 0.5 if the name says "Coming soon" – PanosG Jun 06 '18 at 12:04
  • I'm sorry , the POitem class i have created is for the markerInfoWindow which comes from .xib file...So i will try your way above – PanosG Jun 06 '18 at 15:27
  • Finally it works..! I followed the steps of the 2nd answer implementing the MarkerManager.h from this question https://stackoverflow.com/questions/38547622/how-to-implement-gmuclusterrenderer-in-swift – PanosG Jun 07 '18 at 11:02