Convert span value into meters on a mapview

前端 未结 6 814
小鲜肉
小鲜肉 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:41

    Swift 4

    extension MKMapView {
      func regionInMeter() -> CLLocationDistance {
        let eastMapPoint = MKMapPointMake(MKMapRectGetMinX(visibleMapRect), MKMapRectGetMidY(visibleMapRect))
        let westMapPoint = MKMapPointMake(MKMapRectGetMaxX(visibleMapRect), MKMapRectGetMidY(visibleMapRect))
    
        return MKMetersBetweenMapPoints(eastMapPoint, westMapPoint)
      }
    }
    

提交回复
热议问题