last day (15 days later) » 

12:13 AM
0
Q: Zoom into MKMapItem

ErikI need to zoom into a MKMapItem that is passed with a NSNotification and handled like so: -(void)zoomToAnnotation:(NSNotification *)notification { // Zoom into the passed MKMapItem MKMapItem *passedMapItem = notification.object; // self.previewMapView is the what I called my mapView } UPDATE: ...

 
would setCamera:Animated: passing the MKCamera parameter with a centerCoordinate with a coordinate coming from the annotation? Or something conformating to the MKAnnotation protocol?
 
@LouisTur thought of something similar myself, but I don't know how to get the coordinate of the MKMapItem.
 
looks like you need to access the placemark property which is an MKPlacemark class which conforms to the MKAnnotation protocol, meaning you can call it's coordinate property
 
@LouisTur Seems to freeze during setCamera:animated, see my update. It logs "beginCam" but not "endCam" and the simulator UI gets frozen. Any ideas for that?
 
update and put a breakmark after the line MKMapItem * passedMapItem = (MKMapItem *)notification.object and make sure that it's actually a MKMapItem. Also, log out what notification.object is... or maybe if wrap it all in a conditional: if([notification.object respondsToSelector:@selector(openInMapsWithLaunchOptions:){ }
 
12:13 AM
@LouisTur Looks like it's a MKMapItem - though it says" (int)" - what's that? See update 2
 
means it's likely not a MKMapItem, even though we're trying to typecast is as such. At that same breakpoint, what does it list notification.object as? What does your code for the notification look like?
Oh woah.. had no idea we could make this a chat
this is pretty neat
 
 
11 hours later…
11:08 AM
Hi, you there now? Sorry I didn't see your message yesterday, I had to leave as it was getting quite late
 
11:21 AM
this is the code I'm using to post the notification:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Post notification and pass the selected row
MKMapItem *selectedMapItem = self.searchResults[indexPath.row];
[[NSNotificationCenter defaultCenter] postNotificationName:@"zoomToAnnotation" object:selectedMapItem];
}
I logged out the name property of the passed MKMapItem and it logs out the place it contains - so looks like it's indeed a MKMapItem
 
12:01 PM
@LouisTur
 
 
12 hours later…
11:59 PM
instead of passing the selectedMapItem to your notification handler, pass its actual coordinates inside of the userDict parameter of postNotificationName:object:userInfo: that or even just try to implement the MK method on itself to make sure at least we have that part right. maybe we're not calling the method correctly?
 

  last day (15 days later) »