ios - How to get radius from visible area of MKmapview? -


i able visible rectangle of map view , centre point of map view , span deltas mkmaap view methods: visible :mapview.visiblemaprect used . centre point: map view.centercoordinate used , span: mapview.region.span used.

now have information, how can calculate radius of visible using calculation? can explain me in detail?

i have seen this question answer giving me span not radius of visible area.

to radius follow this:

- (cllocationdistance)getradius {     cllocationcoordinate2d centercoor = [self getcentercoordinate];     // init center location center coordinate     cllocation *centerlocation = [[cllocation alloc] initwithlatitude:centercoor.latitude longitude:centercoor.longitude];      cllocationcoordinate2d topcentercoor = [self gettopcentercoordinate];     cllocation *topcenterlocation = [[cllocation alloc] initwithlatitude:topcentercoor.latitude longitude:topcentercoor.longitude];      cllocationdistance radius = [centerlocation distancefromlocation:topcenterlocation];      return radius; } 

it return radius in metres.

to center coordinate

- (cllocationcoordinate2d)getcentercoordinate {     return [self.mapview centercoordinate]; } 

for getting radius, depends on want 2nd point. lets take top center

- (cllocationcoordinate2d)gettopcentercoordinate {     // coordinate cgpoint of map     return [self.mapview convertpoint:cgpointmake(self.mapview.frame.size.width / 2.0f, 0) tocoordinatefromview:self.mapview]; } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -