mkcoordinateregion

How to make the union between two MKCoordinateRegion

依然范特西╮ 提交于 2019-11-28 10:24:16
I'm trying to do the union between two MKCoordinateRegion. Does anybody have an idea on how to do this? There is a MKMapRectUnion function which accepts two MKMapRects so you could first convert each MKCoordinateRegion to an MKMapRect and then call that function (and convert the result back to an MKCoordinateRegion using the MKCoordinateRegionForMapRect function). The conversion method might look like this: - (MKMapRect)mapRectForCoordinateRegion:(MKCoordinateRegion)coordinateRegion { CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(coordinateRegion.center.latitude +

MKMapView show incorrectly saved region

风流意气都作罢 提交于 2019-11-27 09:14:00
I'm saving map region into user defaults when my iPhone app is closing like this: MKCoordinateRegion region = mapView.region; [[NSUserDefaults standardUserDefaults] setDouble:region.center.latitude forKey:@"map.location.center.latitude"]; [[NSUserDefaults standardUserDefaults] setDouble:region.center.longitude forKey:@"map.location.center.longitude"]; [[NSUserDefaults standardUserDefaults] setDouble:region.span.latitudeDelta forKey:@"map.location.span.latitude"]; [[NSUserDefaults standardUserDefaults] setDouble:region.span.longitudeDelta forKey:@"map.location.span.longitude"]; When app

How to make the union between two MKCoordinateRegion

匆匆过客 提交于 2019-11-27 03:35:44
问题 I'm trying to do the union between two MKCoordinateRegion. Does anybody have an idea on how to do this? 回答1: There is a MKMapRectUnion function which accepts two MKMapRects so you could first convert each MKCoordinateRegion to an MKMapRect and then call that function (and convert the result back to an MKCoordinateRegion using the MKCoordinateRegionForMapRect function). The conversion method might look like this: - (MKMapRect)mapRectForCoordinateRegion:(MKCoordinateRegion)coordinateRegion {

How to check if MKCoordinateRegion contains CLLocationCoordinate2D without using MKMapView?

て烟熏妆下的殇ゞ 提交于 2019-11-27 00:37:52
问题 I need to check if user location belongs to the MKCoordinateRegion. I was surprised not to find simple function for this, something like: CGRectContainsCGPoint(rect, point) . I found following piece of code: CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(region.center.latitude + (region.span.latitudeDelta/2.0), region.center.longitude - (region.span.longitudeDelta/2.0)); CLLocationCoordinate2D bottomRightCoordinate = CLLocationCoordinate2DMake(region.center.latitude -

MKMapView show incorrectly saved region

a 夏天 提交于 2019-11-26 17:49:00
问题 I'm saving map region into user defaults when my iPhone app is closing like this: MKCoordinateRegion region = mapView.region; [[NSUserDefaults standardUserDefaults] setDouble:region.center.latitude forKey:@"map.location.center.latitude"]; [[NSUserDefaults standardUserDefaults] setDouble:region.center.longitude forKey:@"map.location.center.longitude"]; [[NSUserDefaults standardUserDefaults] setDouble:region.span.latitudeDelta forKey:@"map.location.span.latitude"]; [[NSUserDefaults

Convert MKCoordinateRegion to MKMapRect

喜夏-厌秋 提交于 2019-11-26 15:27:46
问题 I have a square MKMapView in my app, and I wish to set a center point and the exact height/width of the view in meters. Creating an MKCoordinateRegion and setting the map to it (as in this code... MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(center_coord, 1000.0, 1000.0); [self.mapView setRegion:region animated:YES]; ..) doesn't work properly because using regions here just means that at least that region is displayed, typically more than the region is. I'm planning on using