【问题标题】:How to show all Info window in iOS Google maps without tapping on Marker?如何在不点击标记的情况下在 iOS 谷歌地图中显示所有信息窗口?
【发布时间】:2014-07-12 07:29:42
【问题描述】:

我正在尝试在不点击的情况下创建标记。但我无法显示所有 infoWindows。它只在最后一个标记上显示一个信息窗口。

这是我的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableArray *markersArray = [[NSMutableArray alloc] init];
    for(int i=0; i<10; i++){
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.position = CLLocationCoordinate2DMake(latitude, longitude);
        marker.appearAnimation=YES;
        marker.opacity = 0.0;
        mapView.selectedMarker = marker;
        marker.map = mapView;
        [markersArray addObject:marker];
    }
}

和自定义信息窗口:

- (UIView*)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
    CustomInforwindow *customView =  [[[NSBundle mainBundle] loadNibNamed:@"CustomInforwindow" owner:self options:nil] objectAtIndex:0];
    return customView;
}

【问题讨论】:

  • 将两个标记放在同一个位置(务必在两者之间保持一些间隙)并消除两者的交互。例如marker1.position=Locationcoorsinate2dobject; marker2.position=位置坐标2d对象;| marker1.tappable=false; marker2.tappable=false;现在魔法就要发生了 marker2.groundanchor=CGPointMake(marker1.groundanchor.x,marker1.gorundanchor.y+2‌​.7);希望这有助于快乐编码:)

标签: ios google-maps google-maps-markers infowindow google-maps-sdk-ios


【解决方案1】:

您一次可以显示一个信息窗口。

mapView.selectedMarker = marker; this will open the infowindow for the last marker

如果你想显示多个标记,那么你应该制作包含标记和信息窗口的标记。

希望这会有所帮助。

【讨论】:

  • 如果我想打开多个窗口,有可能吗?我的要求是打开多个窗口
  • 感谢您的回复。任何替代解决方案?
  • 您可以将标记图像作为所选标记图像
  • 感谢您的建议。我会努力落实您的建议。
  • 将两个标记放在同一个位置(务必在两者之间保持一些间隙)并消除两者的交互。例如marker1.position=Locationcoorsinate2dobject; marker2.position=位置坐标2d对象;| marker1.tappable=false; marker2.tappable=false;现在魔法就要发生了 marker2.groundanchor=CGPointMake(marker1.groundanchor.x,marker1.gorundanchor.y+2.7);希望这有助于快乐编码:)
【解决方案2】:

将两个标记放在同一个位置(在两者之间保持一定的间隙)并消除两者的交互。例如:

marker1.position = Locationcoorsinate2dobject;
marker2.position = Locationcoorsinate2dobject;
marker1.tappable = false; 
marker2.tappable = false; 

现在魔法就要发生了:

marker2.icon = [UIImage imageNamed:@"yourinfowindow.png"];
marker2.groundanchor = CGPointMake(marker1.groundanchor.x, marker1.gorundanchor.y + 2‌​.7);

希望这有助于快乐编码:)

【讨论】:

    猜你喜欢
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 2013-09-13
    • 2014-10-15
    • 1970-01-01
    • 2017-07-26
    • 2017-05-08
    相关资源
    最近更新 更多