Reputation: 31
In my application, I am using GoogleMaps
and a custom GMSMarker
. However, my markers are dynamically calculated to decide what they should render or not. For example, when a marker is too close to another, I have a logic for overlap to display or not the title of the marker etc.
My problem started when using many markers, the performance of the app dropped below 40fps. Therefore, I began initializing my markers with the property tracksViewChanges = false
.
This solved my performance problem, but my markers stopped updating their views. By setting the value of tracksViewChanges
back to true and then to false again, the markers work almost perfectly, except that every time I change the value, they 'flash' on the screen.
Does anyone know how to solve this?
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.updatePinOverlap(mapView: mapView)
}
}
func updatePinOverlap(mapView: GMSMapView) {
for marker in self.discoveryMarker {
marker.tracksViewChanges = true
marker.applyOverlapping(pinType: model.pinType ?? .medium,
index: model.zIndex ?? 0)
marker.tracksViewChanges = false
}
}
As mentioned earlier, I tried changing the state of tracksViewChanges, I tried using only UIImage, I tried adding animation to the view, but nothing that really solves my problem.
Upvotes: 2
Views: 194