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

Cannot add annotation before -[MKMapViewDelegate mapViewWillStartLoadingMap:] #7

Open
stefanfisk opened this issue Mar 15, 2012 · 4 comments

Comments

@stefanfisk
Copy link

If -[MKMapView addAnnotation:] is called before -[MKMapViewDelegate mapViewWillStartLoadingMap:] it fails with the following message: "Error creating internal representation of annotation view for annotation: <MKPointAnnotation: 0x7fc514969060> <0.000000, 0.000000> Pin Title - (null)".

Also, -[MKMapView setCenterCoordinate:] seems to have no effect until after -[MKMapViewDelegate mapViewWillStartLoadingMap:].

This is not consistent with MKMapView on iOS. I'd assume that the root cause is related to the web view not having loaded properly before -[MKMapViewDelegate mapViewWillStartLoadingMap:], but I have not investigated it further as it is fairly easy to work around.

@rickfillion
Copy link
Member

You're right.

The reason for this is that the objc code routes those calls to javascript, and before you get that delegate call, the JS isn't ready to accept requests yet (things are in the process of loading). So the fix would be to have a way to queue those calls up until things are ready, then when it's ready, execute everything on the queue again.

@LucasDeVil
Copy link

This is quite an annoying behaviour. I'm loading the locations at application startup and post a notification that there is new data.
This happens way before -mapViewWillStartLoadingMap: and I have no clue how I could queue this event.
The notification is posted in awakeFromNib.

In addition -mapViewWillStartLoadingMap: isn't called (using 10.7.4).

@rickfillion
Copy link
Member

Waiting for -[MKMapViewDelegate mapViewDidFinishLoadingMap:] is likely the better fix.

I agree that it's annoying behaviour, but I'm I've got zero cycles to throw at this for the time being. You can either work around it, or attempt to fix it yourself.

I just tested here and mapViewDidFinishLoadingMap does get called on 10.7.4, whereas willStartLoadingMap seems to not be called (I'd have to look into that).

@LucasDeVil
Copy link

Thank you for this suggestion. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants