mapView: didTapMarker isn't selecting a marker

北慕城南 提交于 2019-12-12 02:49:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!