当我使用 Google 地图放大和缩小时...调用的是什么函数?
When I zoom in and out with Google Maps...what function being called?
我在 UIViewController 中有一个 google 地图。当我放大和缩小时...我要写什么方法来访问 iOS Swift?当用户调整视图时,我想知道当前地图半径。这个逻辑是 touchesBegan 还是 google 有我可以实现的功能?如果 google 没有,touchesBegan 是最好的方法吗?我现在有这样的东西......但它不起作用。
var mapRadius: Double {
get {
let region = mapView.projection.visibleRegion()
let verticalDistance = GMSGeometryDistance(region.farLeft, region.nearLeft)
let horizontalDistance = GMSGeometryDistance(region.farLeft, region.farRight)
return max(horizontalDistance, verticalDistance)*0.5
}
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
for touch:AnyObject in touches {
NSLog("MapRadius: \(mapRadius)");
}
}
这就是我要找的。我不知道为什么我花了这么长时间才找到...
func mapView(mapView: GMSMapView!, didChangeCameraPosition position: GMSCameraPosition!) {
print(position)
}
我在 UIViewController 中有一个 google 地图。当我放大和缩小时...我要写什么方法来访问 iOS Swift?当用户调整视图时,我想知道当前地图半径。这个逻辑是 touchesBegan 还是 google 有我可以实现的功能?如果 google 没有,touchesBegan 是最好的方法吗?我现在有这样的东西......但它不起作用。
var mapRadius: Double {
get {
let region = mapView.projection.visibleRegion()
let verticalDistance = GMSGeometryDistance(region.farLeft, region.nearLeft)
let horizontalDistance = GMSGeometryDistance(region.farLeft, region.farRight)
return max(horizontalDistance, verticalDistance)*0.5
}
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
for touch:AnyObject in touches {
NSLog("MapRadius: \(mapRadius)");
}
}
这就是我要找的。我不知道为什么我花了这么长时间才找到...
func mapView(mapView: GMSMapView!, didChangeCameraPosition position: GMSCameraPosition!) {
print(position)
}