前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IOS MapView 用法

IOS MapView 用法

作者头像
全栈程序员站长
发布2022-07-05 09:12:03
4310
发布2022-07-05 09:12:03
举报
文章被收录于专栏:全栈程序员必看

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

IOS MapView 用法
IOS MapView 用法
IOS MapView 用法
IOS MapView 用法

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/110369.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年8月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档