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

visibleDistanceを小さい数値に変更します。気に入ったものが見つかるまで試してみてください。

于 2014-11-28T06:16:21.800 に答える