Comments (8)
Thanks for reporting this issue!
It's expected that updateAnnotationsWithCompletionHandler:
gets called when you call setCenterCoordinate:animated:
. Surprisingly, though, the cell size in map point units returned by CCHMapClusterControllerMapLengthForLength
changes. That's why the clusters rearrange.
I have no idea why the cell size changes when calling setCenterCoordinate:animated:
but not when panning the map through use interactions.
If you print out the cell size returned by CCHMapClusterControllerMapLengthForLength
, you can see that the cell size is bigger when selecting a cluster further north and smaller when selecting one that's further south.
Really strange.
from cchmapclustercontroller.
Thanks for your answer!
I have the feeling, that Apple is internally using setRegion:animated:
whenever you use setCenterCoordinate:animated:
. There it says:
Changing just the center coordinate of the region can still cause the span values to change
implicitly. The span values might change because that the distances represented by a span
change at different latitudes and longitudes and the map view may need to adjust the span
to account for the new location. If you want to change the center coordinate without
changing the zoom level, use the setCenterCoordinate:animated: instead.
But the last part does not seem to be true, really weird. I've checked OpenRadar, if this is a known issue, but no luck so far.
from cchmapclustercontroller.
You are right, the zoom changes. It seems to be a problem specific to iOS 7. I can't reproduce this on iOS 6, but I can on iOS 7 and 7.1 Beta 5 (tested on simulator).
As a workaround, I suggest the following code, which avoids zooming in my tests:
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(52.526221, 13.397829);
MKMapPoint point = MKMapPointForCoordinate(location);
MKMapRect rect = [self.mapView visibleMapRect];
rect.origin.x = point.x - rect.size.width * 0.5;
rect.origin.y = point.y - rect.size.height * 0.5;
[self.mapView setVisibleMapRect:rect animated:YES];
@plu Could you please have a look whether this solves your problem?
from cchmapclustercontroller.
This does fix my problem, thanks a lot! You can close this ticket, if you want to :).
Maybe we should file a Radar then for iOS 7? The other day I was already looking into OpenRadar for similar issues, but could not identify any.
from cchmapclustercontroller.
I added a code example for this to the documentation. Thanks again for reporting this issue.
from cchmapclustercontroller.
I'm still facing issues even with using setVisibleMapRect:animated:
. In my app I want to center the map whenever the user selects an annotation. In general this works fine, but in case of a big zoom level, the map view somehow ignores the CGRect
that I pass to setVisibleMapRect:animated:
. After setting the rect, I end up with a bigger rect than I originally passed in. I couldn't find any solutions so far. Have you experienced a similar behaviour?
from cchmapclustercontroller.
I've done some testing with mapRectThatFits:(MKMapRect)mapRect
before setting the rect via setVisibleMapRect:(MKMapRect)mapRect animated:(BOOL)animate
like described in the docs.
According to the Apple Docs, I assume that the return value of mapRectThatFits:(MKMapRect)mapRect
should match the rect that will be applied internally when using setVisibleMapRect:(MKMapRect)mapRect animated:(BOOL)animate
The funny (or annoying) thing is that the calculated rect via
MKMapRect rect = [self.mapView visibleMapRect];
rect.origin.x = point.x - rect.size.width * 0.5;
rect.origin.y = point.y - rect.size.height * 0.5;
never matches the rect returned by [mapView mapRectThatFits:rect]
. The size always differs slightly by random values below 0.5. Probably caused by because of all the internal calculations, rounding and conversions by MapKit?
I haven't found any cool way to set the center coordinate or change the visible map rect by not (slightly) changing mapView.region.span.longitudeDelta
which is used in CCHMapClusterController
to determine if the zoom level changed after changing the map view's region.
I was thinking about adding something like a "zoom change tolerance" so that we ignore marginal zoom changes and only re-cluster when the zoom changed significantly. @choefele what do you think? Should we re-open this issue?
from cchmapclustercontroller.
Hmm, the "zoom change tolerance" prevents the CCHMapClusterController
from undesired deselections. But then it might happen, that a selected annotation disappears because it gets merged into a cluster. This is caused because a marginal change of longitudeDelta
might trigger a "heavy" cluster re-odering like described in #82. Seems like these issues are highly coupled.
from cchmapclustercontroller.
Related Issues (20)
- Annotation views occasionally disappear while panning/zooming HOT 2
- willReuseMapClusterAnnotation does not work in Swift HOT 6
- showAnnotations:animated: adds the default pin instead of custom Annotation Views HOT 1
- Using own custom MKAnnotation subclass for uniqueLocations HOT 4
- Strange behavior when zooming in and out HOT 14
- Two markers at exact same location HOT 1
- How to get the instance of CCHMapClusterAnnotation? HOT 4
- Crash due to usage of KVO HOT 5
- Annotations and clusters get removed randomly when using MKMapTypeHybridFlyover HOT 7
- Cannot refer to custom subclass of MKAnnotation in viewForAnnotation HOT 3
- Cannot tap on Annotation View
- Can't see annotation while too zoomed out HOT 4
- Annotation coordinate is not properly updated HOT 2
- Displaying different annotation views HOT 1
- Make the representation of ClusterAnnotationView unchanged when zooming in or out HOT 5
- changing the annotation view when isUnique changes HOT 2
- Getting wrong annotation count on click of cluster in swift 3 HOT 1
- TV OS? HOT 1
- Removing Annotations doesn't work correctly HOT 6
- Is it possible for clusters to have sub clusters?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cchmapclustercontroller.