Mapview Android - 相机目标界限

时间:2018-03-07 12:45:18

标签: android ios android-mapview

我想在mapview android中创建一个限制区域。用户无法出门。 我在ios中知道了以下代码:

- // MARK: Visible region UAE
static let nearLeft = CLLocationCoordinate2DMake(24.167223, 51.613329)
static let nearRight = CLLocationCoordinate2DMake(26.293829, 56.425340)
static let farLeft = CLLocationCoordinate2DMake(22.675273, 55.205858)
static let farRight = CLLocationCoordinate2DMake(24.177246, 55.985887)


class func visibleRegionMapView(nearLeft: CLLocationCoordinate2D, nearRight: CLLocationCoordinate2D, farLeft: CLLocationCoordinate2D, farRight: CLLocationCoordinate2D, mapView: GMSMapView) {
    let visibleRegion = GMSVisibleRegion(nearLeft: nearLeft, nearRight: nearRight, farLeft: farLeft, farRight: farRight)
    let bounds = GMSCoordinateBounds(region: visibleRegion)
    mapView.cameraTargetBounds = bounds
}
  • 我无法在android中找到:cameraTargetBounds,CoordinateBounds,ect..like ios
  • 我尝试使用map.setLatLngBoundsForCameraTarget(),但这不是我的愿望。
  • 我也尝试map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds,0));但它没有限制范围。用户可以环游世界。

每个人都知道如何在Android上像上面的ios代码一样设置相机界限?或者引用的文件对我有好处。

最好的问候。

0 个答案:

没有答案