How can I get a finer grained span in my MKMapView

前端 未结 2 1404
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 16:03

I\'m using an MKMapView and I\'m initializing like this:

homeLocation.latitude = 42.033126;
homeLocation.longitude = -70.168621;

[self.mapView setCenterCoordina         


        
相关标签:
2条回答
  • 2021-01-21 16:27

    Have you tried on the device? Sometimes I have more control on the zoom level on the device than on the simulator.

    0 讨论(0)
  • 2021-01-21 16:36

    MKCoordinateSpanMake uses degrees, and 1 degree is about 69 miles. If you want a more fine grained setting, use MKCoordinateRegionMakeWithDistance instead.

    CLLocationCoordinate2D homeLocation;
    homeLocation.latitude = 42.033126;
    homeLocation.longitude = -70.168621;
    
    [self.mapView setCenterCoordinate:homeLocation animated:NO];
    
     MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance( homeLocation, 200000, 200000);
    // 200000 meter is approximately 1.8 degree
    [self.mapView setRegion:[self.mapView regionThatFits:viewRegion] animated:NO];
    
    0 讨论(0)
提交回复
热议问题