当用户移动地图时,将调用以下函数。
有可能获得视口吗?视口是北纬、东经和拉特。还有。南部/西部的。
func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool){
print("The \(mapView.centerCoordinate)")
print("the maprect \(mapView.visibleMapRect.origin)")
print("the maprect \(mapView.visibleMapRect.size)")
//I find just this attributes for mapView
}
我不知道如何从我的数据中提取视图。我在网上找不到任何东西。
目的是用google分析和另一个工具来记录坐标,评估数据。
有人有主意吗?非常感谢
发布于 2016-04-07 12:47:50
MapKit
let northEast = mapView.convertPoint(CGPoint(x: mapView.bounds.width, y: 0), toCoordinateFromView: mapView)
let southWest = mapView.convertPoint(CGPoint(x: 0, y: mapView.bounds.height), toCoordinateFromView: mapView)
googleMaps
mapView有一个属性“投影”,可以使用"coordinateForPoint“将点从mapView转换为坐标。因此,以下几点可以发挥作用:
谷歌地图maps 3
let northEast = mapView.projection.coordinate(for: CGPoint(x: mapView.layer.frame.width, y: 0))
let southWest = mapView.projection.coordinate(for: CGPoint(x: 0, y: mapView.layer.frame.height))
swift 2
let northEast = mapView.projection.coordinateForPoint(CGPoint(x: mapWidth, y: 0 ))
let southWest = mapView.projection.coordinateForPoint(CGPoint(x: 0, y: mapHeight))
你只需要输入你的mapView宽度和高度
https://stackoverflow.com/questions/36476163
复制相似问题