问题
I have a GMSMapView
with a lot of markers, every marker represents one store of my client, every time the user approaches to one of the markers (to one of the stores) he gets a notification with the address of the store.
I want that when the user taps on a notification (opens the app via notification) the marker will be presented on the map (already selected).
Note: the marker is a property for every Store
object, the UILocalNotification
stores the Store
object's identifier and that's how I find the correct store.
Note 2: I'm working with Google Maps iOS SDK
.
I've tried to do it like this:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSString *storeIdentifier=[[notification userInfo] objectForKey:@"storeIdentifier"];
Store *notificationsStore=[self.monitorLocationVC storeForIdentifier:storeIdentifier];
[self.myVC mapView:self.myVC.mapView didTapMarker:notificationsStore.marker];
}
For some reason, the marker isn't being selected when the user opens the app.
I've override mapView: didTapMarker:
on myVC.m
like that:
-(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
return NO;
}
回答1:
didTapMarker
is on GMSMapViewDelegate
, it's called by the map to notify your code that the marker has been tapped. It doesn't tap the marker.
You can however set selectedMarker
on the map view, to cause that marker to be selected, and to show its info window (if it has one). For example:
self.myVC.mapView.selectedMarker = notificationsStore.marker;
See here for more examples: How to show a Info window in iOS Google maps without tapping on Marker?
回答2:
-(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
viewIwant.hidden=NO;
//or any nib you want
return YES;
}
来源:https://stackoverflow.com/questions/35560480/mapview-didtapmarker-isnt-selecting-a-marker