[code]
//
// UIgmapDemoViewController.h
// UIgmapDemo
//
// Created by Administrator on 13/3/6.
// Copyright (c) 2013年 Administrator. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface UIgmapDemoViewController : UIViewController
{
//MKMapView *mapView;
}
@property (weak,nonatomic) IBOutlet MKMapView *mapView;
@end
[/code]
[code]
//
// UIgmapDemoViewController.m
// UIgmapDemo
//
// Created by Administrator on 13/3/6.
// Copyright (c) 2013年 Administrator. All rights reserved.
//
#import "UIgmapDemoViewController.h"
#define METERS_PER_MILE 1609.344
@interface UIgmapDemoViewController ()
@end
@implementation UIgmapDemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated
{
// 1
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 39.281516;
zoomLocation.longitude= -76.580806;
// 2
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
// 3
[_mapView setRegion:viewRegion animated:YES];
}
@end
[/code]
//
// UIgmapDemoViewController.h
// UIgmapDemo
//
// Created by Administrator on 13/3/6.
// Copyright (c) 2013年 Administrator. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface UIgmapDemoViewController : UIViewController
{
//MKMapView *mapView;
}
@property (weak,nonatomic) IBOutlet MKMapView *mapView;
@end
[/code]
[code]
//
// UIgmapDemoViewController.m
// UIgmapDemo
//
// Created by Administrator on 13/3/6.
// Copyright (c) 2013年 Administrator. All rights reserved.
//
#import "UIgmapDemoViewController.h"
#define METERS_PER_MILE 1609.344
@interface UIgmapDemoViewController ()
@end
@implementation UIgmapDemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated
{
// 1
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 39.281516;
zoomLocation.longitude= -76.580806;
// 2
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);
// 3
[_mapView setRegion:viewRegion animated:YES];
}
@end
[/code]