#import <UIKit/UIKit.h>

 @interface AppDelegate : UIResponder <UIApplicationDelegate>

 @property (strong, nonatomic) UIWindow *window;

 @end
 #import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; self.window.rootViewController = [[RootViewController alloc] init]; [self.window makeKeyAndVisible];
return YES;
} @end
 #import <UIKit/UIKit.h>

 @interface RootViewController : UIViewController

 @end
 #import "RootViewController.h"
#import <MapKit/MapKit.h>
#import "YXYCAnation.h"
@interface RootViewController ()<MKMapViewDelegate> @end @implementation RootViewController - (void)viewDidLoad {
[super viewDidLoad];
// 初始化MKMapView
MKMapView *mapView = [[MKMapView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 设置代理
mapView.delegate = self;
// 设置显示当前位置
mapView.showsUserLocation = YES;
// 设置地图显示类型
mapView.mapType = MKMapTypeStandard;
// 经纬度
CLLocationCoordinate2D coord2D = {23.117000,113.27500};
// 显示范围精度
MKCoordinateSpan span = {0.01,0.01};
// 显示区域
MKCoordinateRegion region = {coord2D,span};
// 给地图设置显示区域
[mapView setRegion:region animated:YES];
[self.view addSubview:mapView]; // 创建anation对象
CLLocationCoordinate2D showCoord = {23.117000,113.27500};
YXYCAnation *anation1 = [[YXYCAnation alloc] initWithCoordinate2D:showCoord];
anation1.title = @"越秀公园";
anation1.subtitle = @"小标题";
[mapView addAnnotation:anation1];
} #pragma mark -MKAnnotationView delegate-
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *identifier = @"Annotion";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotationView reuseIdentifier:identifier];
annotationView.image = [UIImage imageNamed:@""];
}
return annotationView;
} - (void)buttonAction:(UIButton *)sender
{
NSLog(@"显示公园简介");
} @end
 #import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface YXYCAnation : NSObject<MKAnnotation> @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle; - (id)initWithCoordinate2D:(CLLocationCoordinate2D)coordinate; @end
 #import "YXYCAnation.h"

 @implementation YXYCAnation

 - (id)initWithCoordinate2D:(CLLocationCoordinate2D)coordinate
{
self = [super init];
if (self != nil) {
_coordinate = coordinate;
}
return self;
} @end

最新文章

  1. 前端组件化Polymer入门教程(8)——事件
  2. php 两段文本对比,不同的文字显示高亮
  3. 语义化HTML:ul、ol和dl
  4. android 基本布局(RelativeLayout、TableLayout等)使用方法及各种属性
  5. PAT 1016. 部分A+B (15)
  6. 为什么使用ConcurrentHashMap
  7. js控制文本框只能输入数字 及 常用字符对应ASCII码值
  8. 如何使盘ISO图像文件
  9. java中String与StringBuffer拼接的区别
  10. 浅谈canvas绘画王者荣耀--雷达图
  11. Frogger POJ - 2253
  12. Raid5两块硬盘掉线可以恢复数据吗_raid数据恢复案例分享
  13. Unable to instantiate Action, MenuAction, defined for &#39;QueryMenuAll&#39; in namespace &#39;/&#39;MenuAction
  14. php使用redis的几种常见方式和用法
  15. Array 新增加的一些API用法
  16. 关于spring事务
  17. node的模块包装为promise写法
  18. 【转】前端Web开发MVC模式-入门示例
  19. ES6标准入门之变量的解构赋值简单解说
  20. java并发基础(三)--- 任务执行

热门文章

  1. AI探索(二)Tensorflow环境准备
  2. spark 稠密向量和稀疏向量
  3. MySql数据库约束
  4. [Wc2009]shortest
  5. 转:django关于csrf防止跨站的ajax请求403处理
  6. 【转载,实测好用】gitlab结合sourcetree使用
  7. poj 3463 Sightseeing——次短路计数
  8. VisualPage重定向
  9. CentOS 7安装Azcopy
  10. [转载]Ubuntu下ssh服务的安装与登陆(ssh远程登陆)