kuz*_*zdu 4 google-analytics viewport ios android-mapview swift
用户移动地图时会调用以下函数.
有可能获得视口吗?视口是北/东和纬度的经度和纬度.和lon.南/西.
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
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何从我的数据中获取视口.我在www中找不到任何东西.
目的地是我使用谷歌分析记录坐标,另一个工具评估数据.
有人有想法吗?非常感谢
小智 10
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)
Run Code Online (Sandbox Code Playgroud)
谷歌地图
mapView有一个属性"projection",你可以使用"coordinateForPoint"将一个点从mapView转换为一个坐标.以下可能有效:
swift 3 for google maps
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))
Run Code Online (Sandbox Code Playgroud)
迅捷2
let northEast = mapView.projection.coordinateForPoint(CGPoint(x: mapWidth, y: 0 ))
let southWest = mapView.projection.coordinateForPoint(CGPoint(x: 0, y: mapHeight))
Run Code Online (Sandbox Code Playgroud)
你只需要输入你的mapView宽度和高度
归档时间: |
|
查看次数: |
1826 次 |
最近记录: |