0
votes

In Android on tapping on a marker two buttons show on the screen at the bottom for direction and opening google maps. However, on iOS tapping marker only shows info window.

I need to show the info window and directions and google maps buttons on tapping marker just as in Android.

My code for adding markers:

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = [(CLLocation*)dict[@"position"] coordinate];
marker.icon = [GMSMarker markerImageWithColor:[UIColor ubnBlue]];
marker.title = dict[@"title"];
marker.snippet = dict[@"snippet"];
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.tappable = YES;
marker.map = mapView_;
3
I will help youuser3182143

3 Answers

0
votes

First set GMSMapViewDelegate method

- (BOOL) mapView: (GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
    [mapView setSelectedMarker:marker];
    return YES;
}

- (UIView *GMS_NULLABLE_PTR)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker
{
   NSLog(@"The amrker snippet is - %@",marker.snippet);
   if([marker.snippet isEqualToString:@"your string"]) //check here
   {
       ....//Do the stuff here
   }
}
0
votes

First, you need to set the delegate method in yourController.h file then you can handle it by using the method

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {

return Yes;

}

to show the info window you need to call a marker.title = @"title";

0
votes

GMSMarker has property iconView. You can assign UIView to iconView.

Implement GMSMapViewDelegate delegate methods

(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {

}

Now you can change your view as you need.