苹果地图定位和显示区域

//
//  ViewController.m
//  mapdemo001
//
//  Created by apple on 14-4-28.
//  Copyright (c) 2014年 apple. All rights reserved.
//

#import "ViewController.h"
#import <MapKit/MapKit.h>

@interface ViewController () <MKMapViewDelegate>
{
    MKMapView *_mapview;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    MKMapView *mapview = [[MKMapView alloc] initWithFrame:self.view.bounds];
    mapview.delegate = self;
    mapview.showsUserLocation = YES;
    [self.view addSubview:mapview];
}

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    if (_mapview) {
        return;
    }
    //设置中心位置
    [mapView setCenterCoordinate:userLocation.location.coordinate];
    //设置跨度
    MKCoordinateSpan span = MKCoordinateSpanMake(0.102988, 0.078449);
    //显示区域
    MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.location.coordinate, span);
    
    //设置显示区域
    [mapView setRegion:region animated:YES];
    _mapview = mapView;
}

- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
{
    NSLog(@"%f %f",mapView.region.span.latitudeDelta,mapView.region.span.longitudeDelta);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

苹果地图定位和显示区域,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。