ios - 单击时将 GMSMarker 置于底部

标签 ios swift google-maps-sdk-ios

单击 GMSMarker 并打开 InfoWindow 时,相机移动到 GMSMarker 位于 GMSMapView< 中心的位置。如何更改移动时标记位于底部的相机移动位置?

当我在没有 InfoWindow 的情况下实现 GMS didTapMarker delegate 方法时,一切都很好:

func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {

    var point = mapView.projection.pointForCoordinate(marker.position)
    point.y = point.y - 200

    let camera = GMSCameraUpdate.setTarget(mapView.projection.coordinateForPoint(point))
    mapView.animateWithCameraUpdate(camera)

    return true
}

它将标记定位在底部。但是,如果我 返回 false,它会显示 InfoWindow 并且标记再次居中。

最佳答案

mapView.selectedMarker = markerdidTapMarker delegate 方法中丢失。该方法应如下所示:

func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {

    var point = mapView.projection.pointForCoordinate(marker.position)
    point.y = point.y - 150

    let camera = GMSCameraUpdate.setTarget(mapView.projection.coordinateForPoint(point))
    mapView.animateWithCameraUpdate(camera)
    mapView.selectedMarker = marker
    return true
}

关于ios - 单击时将 GMSMarker 置于底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38828600/

相关文章:

ios - 在更新功能中开始倒计时

swift - 检测是否有 init?在另一个初始化器中返回 nil

ios - 当我点击 Google Maps SDK for iOS 中的另一个标记时,我可以拦截标记取消选择吗?

android - AndroidRuntime:重要异常(exception):androidmapsapi-ZoomTableManager

IOS/objective-C : Display live camera preview on load without image picker controller

ios - 使用 Floaty 库显示矩形按钮

ios - iPhone : Get the file path which is within subfolder of Resource folder

ios - 在 CoreML 中为循环网络定义可选输入

ios - 使用iOS版Google Maps API无法获取当前位置坐标

ios - 为什么调用 setenv ("OS_ACTIVITY_DT_MODE", "disable", 1) 不会影响日志记录?