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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?