【问题标题】:Google Maps iOS - Tapping on Marker to show default google directions button谷歌地图 iOS - 点击标记以显示默认谷歌方向按钮
【发布时间】:2017-09-06 17:08:47
【问题描述】:

在 Android 中,点击标记时,屏幕底部会显示两个按钮,用于指示方向和打开谷歌地图。但是,在 iOS 上点击标记只显示信息窗口。

我需要在点击标记时显示信息窗口和方向以及谷歌地图按钮,就像在 Android 中一样。

我添加标记的代码:

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_;

【问题讨论】:

  • 我会帮你的

标签: ios objective-c google-maps


【解决方案1】:

第一组GMSMapViewDelegate方法

- (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
   }
}

【讨论】:

    【解决方案2】:

    首先,你需要在你的Controller.h文件中设置委托方法,然后你可以使用该方法来处理它

    - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
    
    return Yes;
    
    }
    

    要显示信息窗口,您需要调用marker.title = @"title";

    【讨论】:

      【解决方案3】:

      GMSMarker 具有 iconView 属性。您可以将 UIView 分配给 iconView。

      实现 GMSMapViewDelegate 委托方法

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

      现在您可以根据需要更改视图。

      【讨论】:

        猜你喜欢
        • 2018-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-06
        • 2018-05-01
        • 1970-01-01
        • 2012-09-27
        • 1970-01-01
        相关资源
        最近更新 更多