0

我正在使用下面给出的代码在地图视图中设置区域:

    CLLocationCoordinate2D loc = (CLLocationCoordinate2D )[self geoCodeUsingAddress:searchBar.text];

    CLLocationDistance visibleDistance = 100000;
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, visibleDistance, visibleDistance);
    MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:region];

    [self.mapView setRegion:adjustedRegion animated:YES];
    [self.mapView setCenterCoordinate:loc];
    [self.mapView setZoomEnabled:YES];

它在一个小区域内显示整个地图。如何增加缩放级别?

4

4 回答 4

1

您还可以借助spanMapView 的价值。动画到那个小区域和跨度地图以缩放所需的值。

使用以下代码:

CLLocationCoordinate2D loc = (CLLocationCoordinate2D )[self geoCodeUsingAddress:searchBar.text];

[UIView animateWithDuration:1.5 animations:^{

    MKCoordinateRegion region;
    region.center.latitude = loc.latitude;
    region.center.longitude = loc.longitude;
    region.span.latitudeDelta = 0.15f;       // Decrement value to zoom
    region.span.longitudeDelta = 0.15f;      // Decrement value to zoom

    [self.mapView setRegion:region animated:YES];

} completion:^(BOOL finished) { }];
于 2014-11-28T06:23:25.390 回答
0

Try this,

CLLocationCoordinate2D loc = (CLLocationCoordinate2D )[self geoCodeUsingAddress:searchBar.text];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, visibleDistance, visibleDistance);
region.span.latitudeDelta = 0.15f;     
region.span.longitudeDelta = 0.15f; 
[self.mapView setRegion:region animated:YES];
[self.mapView setZoomEnabled:YES];
于 2014-11-29T09:00:20.727 回答
0

最后我通过删除解决了这个问题

[self.mapView setCenterCoordinate:loc];

当我删除上述内容时,我工作得很好。

于 2014-11-28T06:55:46.990 回答
0

将 更改visibleDistance为较小的数字。尝试直到找到你喜欢的东西。

于 2014-11-28T06:16:21.800 回答