在iOS中移动Google地图信息窗口

时间:2017-05-01 18:28:30

标签: ios swift google-maps marker infowindow

因此,每当用户点击Google地图中的图钉时,我都会显示一个自定义信息窗口。但是,当用户点击一个引脚而不是默认的引脚上方时,我希望信息窗口出现在屏幕的底部。基本上,当您点击引脚时,地图会像正常情况一样在引脚上居中,但我希望信息窗口显示在屏幕的最底部,位于Google地图徽标上方。我目前正在使用此功能来显示自定义信息窗口:

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> 
UIView? {
    let infoWindow = Bundle.main.loadNibNamed("customInfoWindow", owner: self, options: nil)?.first! as! customInfoWindow
    infoWindow.title.text = marker.title
    return infoWindow
}

1 个答案:

答案 0 :(得分:3)

根据上面的帖子,我认为您需要添加自定义标签而不是默认信息窗口。实现以下委托方法。

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
    // Add a Label on the Map at the desired position,
    // get the coordinates of the marker from 'marker.position'
    // use the coordinates for displaying it in the label or rev geo to get the address and display (according to the required spec.)
}