码迷,mamicode.com
首页 > 移动开发 > 详细

苹果地图定位和显示区域

时间:2014-04-29 17:02:06      阅读:529      评论:0      收藏:0      [点我收藏+]

标签:com   http   class   blog   style   div   img   code   java   javascript   log   

bubuko.com,布布扣
//
//  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
bubuko.com,布布扣

 

苹果地图定位和显示区域,布布扣,bubuko.com

苹果地图定位和显示区域

标签:com   http   class   blog   style   div   img   code   java   javascript   log   

原文地址:http://www.cnblogs.com/damao2012/p/3698064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!