Convert span value into meters on a mapview

前端 未结 6 816
小鲜肉
小鲜肉 2020-12-13 06:56

Whenever the user zoom in or out the map i need to know how many meters are currently represented on the map (width or height).

What i need is the inverse function o

6条回答
  •  一生所求
    2020-12-13 07:53

    Swift 4.2

        func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
    
            let mapRect = mapView.visibleMapRect
            let westMapPoint = MKMapPoint(x: mapRect.minX, y: mapRect.midY)
            let eastMapPoint = MKMapPoint(x: mapRect.maxX, y: mapRect.midY)
            let visibleDistance = westMapPoint.distance(to: eastMapPoint)
        }
    

提交回复
热议问题