Skip to content

Setting annotations in viewDidLoad adds superfluous annotations in Landscape #87

@odrobnik

Description

@odrobnik

If you set up the annotations for your map view controller in viewDidLoad - as suggested in the README then you get a superfluous cluster annotation if presenting the map view controller in Landscape. Note the big "59" cluster on top of ÖSTERREICH.

ios simulator screen shot 23 apr 2015 18 28 24

If you move it to viewWillAppear or later, then this extra cluster does not appear:

ios simulator screen shot 23 apr 2015 18 30 18

I believe that the reason for the misbehavior comes from MKMapView having an incorrect position during viewDidLoad. I added logging for the visible map rect in the -init of CCHMapClusterOperation.

Portrait, viewDidLoad:

Visible map rect = {{141014758.6, 88274850.3}, {6111232.3, 10743653.0}}
Visible map rect = {{141014758.6, 88274850.3}, {6111232.3, 10743653.0}}

Portrait, viewWillAppear:

Visible map rect = {{141014758.6, 88274850.3}, {6111232.3, 10743653.0}}

Landscape, viewDidLoad:

Visible map rect = {{40502319.6, 79459175.3}, {127778493.3, 69020511.0}}
Visible map rect = {{141014758.7, 91996163.0}, {6111232.1, 3301027.8}}

Landscape, viewWillAppear:

Visible map rect = {{141014758.7, 91996163.0}, {6111232.1, 3301027.8}}

The second line in the Landscape-viewDidLoad log comes from this call stack:

screen shot 2015-04-23 at 18 40 37

As you can see there is a timer delay that fixes the visible map rect and calling the mapView:regionDidChange:animated: thus triggering a reclustering.

Putting the setup code into viewWillAppear resolves the issue, but the question for this bug report is, whether the initial clustering shouldn't be delayed until after the first setting of the visible region. The current recommendation and code leads to a superfluous clustering operation.

The second question is, why the second clustering operation does not correct the superfluous cluster annotations that the first one created.

This issue observed on an app with deployment target 8.1, running on 8.3, using a MKMapView from storyboard and size classes throughout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions