IOS MapView 用法

 

mapView use method

 1 。地图编程接口;

 2. 可规划的路线;

 3. 设置书签标记;

 4.周边查找服务。

 

结构 表示 地图上一个点,一个矩形区域,一个大小。 

手机位置服务,导航

typedef struct

{

  CLLocationDegrees latitudeDelta;

  CLLocationDegrees longitudeDelta; 

} MKCoordinateSpan;

 

typedef struct{

   CLLocationCoordinate2D center;

   MKCoordinateSpan span;

}MKCoordinateRegion; 

 

1 .h file

 //  Created by denny chen on 12-7-8.

//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//


#import <UIKit/UIKit.h>

#import <MapKit/MapKit.h>


@interface MapKitViewViewController : UIViewController

{

    MKMapView *MKMapView;

}

@property (retain, nonatomic) IBOutlet MKMapView *mymapkit;


2 .m file

@implementation MapKitViewViewController

@synthesize mymapkit;


- (void)viewDidLoad

{

    [super viewDidLoad];

    //set display jing wei du

CLLocationCoordinate2D center;

    center.latitude=40.029915;

    center.longitude=116.347082;

    

    MKCoordinateSpan span;

    span.latitudeDelta=0.2;

    span.longitudeDelta=0.2;

    MKCoordinateRegion region={center,span};

    

    //set map center location

    [self.mymapkit setRegion:region];

}


- (void)viewDidUnload

{

    [self setMymapkit:nil];

    [super viewDidUnload];

    // Release any retained subviews of the main view.

}


- (void)dealloc {

    [mymapkit release];

    [super dealloc];

}

 

3 create myAnnotation.h file

#import <Foundation/Foundation.h>

#import <MAPkit/Mapkit.h>


@interface myAnnotation : NSObject <MKAnnotation>

    

@end 

4 create myAnnotation.m file

 #import "myAnnotation.h"


@implementation myAnnotation


-(CLLocationCoordinate2D) coordinate

{

    CLLocationCoordinate2D center;

    center.latitude=40.029915;

    center.longitude=116.347082;

    return center;

}


-(NSString *) title

{

  return @"北京大学";

}


-(NSString *) subtitle

{

    return @"你所查寻的位置";

}

@end


4 run reslut

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值