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

I want display multiple cluster images based on markers data #462

Open
VijaykumarPalakurthi opened this issue Mar 18, 2024 · 1 comment
Open
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@VijaykumarPalakurthi
Copy link

VijaykumarPalakurthi commented Mar 18, 2024

Hi all,

I want to display cluster images based on marker data on the cluster, able to update the cluster image but it applies to all the clusters. Please see the bellow screenshot.

Screenshot 2024-03-18 at 3 55 52 PM
func renderer(_ renderer: GMUClusterRenderer, willRenderMarker marker: GMSMarker) {
    let zoom = Int(mapView.camera.zoom)
    let clusteredItems = clusterManager.algorithm.clusters(atZoom: Float(zoom))
    if let clusterItem = marker.userData as? GMUCluster {
        for staticCluster in clusteredItems {
            let movingItems = Double(staticCluster.items.filter { $0.title == "MapsMarkerGreen" }.count)
            let idleItems = Double(staticCluster.items.filter { $0.title == "MapsMarkerBlue" }.count)
            let stoppedLessThan60 = Double(staticCluster.items.filter { $0.title == "MapsMarkerYellow" }.count)
            let stoppedGreaterThan60 = Double(staticCluster.items.filter { $0.title == "MapsMarkerRed" }.count)
            let outOfRange = Double(staticCluster.items.filter { $0.title == "MapsMarkerGrey" }.count)
            let totalItems = staticCluster.items.count
            
            let multiColorBorderView = PercentageColorBorderView(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
            multiColorBorderView.updateBorderColors([(.green, movingItems), (.blue, idleItems), (.yellow, stoppedLessThan60), (.red, stoppedGreaterThan60), (.gray, outOfRange)])
            let countLabel = UILabel(frame: CGRect(x: 2, y: 2, width: 40, height: 40))
            countLabel.text = String(totalItems)
            countLabel.textAlignment = .center
            countLabel.font = UIFont(name: "", size: 15)
            countLabel.textColor = .white
            multiColorBorderView.addSubview(countLabel)
            multiColorBorderView.setNeedsDisplay()
            multiColorBorderView.backgroundColor = .clear
            let clusterImage = multiColorBorderView.asImages()
            marker.icon = clusterImage
        }
    }
}
@VijaykumarPalakurthi VijaykumarPalakurthi added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 18, 2024
@wangela
Copy link
Member

wangela commented Mar 18, 2024

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@VijaykumarPalakurthi Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants