在Android上点击标记时,屏幕底部会显示两个按钮,用于指示和打开谷歌地图。但是,在iOS点击标记上只显示信息窗口。
我需要在点击标记上显示信息窗口和方向以及Google地图按钮,就像在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_;
答案 0 :(得分:0)
首先设置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
}
}
答案 1 :(得分:0)
首先,你需要在yourController.h文件中设置委托方法,然后你可以使用方法来处理它
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
return Yes;
}
显示您需要拨打marker.title = @"title";
答案 2 :(得分:0)
GMSMarker有属性iconView。您可以将UIView分配给iconView。
实施GMSMapViewDelegate委托方法
(BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
}
现在您可以根据需要更改视图。