自定义锚点
来源:互联网 发布:淘宝天下网商店小二 编辑:程序博客网 时间:2024/06/16 04:15
#import "ViewController.h"
#import <MapKit/MapKit.h>
@interface ViewController ()<MKMapViewDelegate>
{
MKMapView *_mapView ;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_mapView = [[MKMapView alloc] initWithFrame:self.view.bounds] ;
_mapView.delegate = self ;
[self.view addSubview:_mapView] ;
CLLocationCoordinate2D center ; // 地图的中心位置
center.latitude = 40.82 ; // 纬度
center.longitude = 114.88 ; // 经度
MKCoordinateSpan span ; // 显示范围
span.latitudeDelta = 0.5 ;
span.longitudeDelta = 0.5 ;
MKCoordinateRegion region = {center,span} ; // 显示区域
[_mapView setRegion:region animated:YES] ; // 地图显示的区域
// 添加锚点
MKPointAnnotation *pointAnno = [[MKPointAnnotation alloc] init] ;
pointAnno.title = @"河北省" ;
pointAnno.subtitle = @"张家口市" ;
pointAnno.coordinate = center ;
// 添加锚点到地图
[_mapView addAnnotation:pointAnno] ;
}
// 自定义锚点
- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *anno = [mapView dequeueReusableAnnotationViewWithIdentifier:@"reuse"] ;
if (!anno) {
anno = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"reuse"] ;
}
anno.image = [UIImage imageNamed:@"8.png"] ;
anno.canShowCallout = YES ; // 可以调出 ?
return anno ;
}
#import <MapKit/MapKit.h>
@interface ViewController ()<MKMapViewDelegate>
{
MKMapView *_mapView ;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_mapView = [[MKMapView alloc] initWithFrame:self.view.bounds] ;
_mapView.delegate = self ;
[self.view addSubview:_mapView] ;
CLLocationCoordinate2D center ; // 地图的中心位置
center.latitude = 40.82 ; // 纬度
center.longitude = 114.88 ; // 经度
MKCoordinateSpan span ; // 显示范围
span.latitudeDelta = 0.5 ;
span.longitudeDelta = 0.5 ;
MKCoordinateRegion region = {center,span} ; // 显示区域
[_mapView setRegion:region animated:YES] ; // 地图显示的区域
// 添加锚点
MKPointAnnotation *pointAnno = [[MKPointAnnotation alloc] init] ;
pointAnno.title = @"河北省" ;
pointAnno.subtitle = @"张家口市" ;
pointAnno.coordinate = center ;
// 添加锚点到地图
[_mapView addAnnotation:pointAnno] ;
}
// 自定义锚点
- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *anno = [mapView dequeueReusableAnnotationViewWithIdentifier:@"reuse"] ;
if (!anno) {
anno = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"reuse"] ;
}
anno.image = [UIImage imageNamed:@"8.png"] ;
anno.canShowCallout = YES ; // 可以调出 ?
return anno ;
}
阅读全文
0 0
- 自定义锚点
- iOS 地图 自定义以及添加锚点
- iOS MapAnchor(地图锚点~自定义)~demo
- eclipse 自定义扩展点
- Eclipse自定义扩展点
- eclipse 自定义扩展点
- 自定义eclipse扩展点
- 自定义扩展点
- 自定义点赞动画
- eclipse自定义扩展点
- 自定义视图注意点
- 自定义View注意点
- 自定义小圆点
- 自定义小圆点详解
- iOS - 自定义红点
- PCL自定义点类型
- SugarCRM自定义入口点
- 自定义View和自定义属性 注意点
- leetcode 72. Edit Distance
- 20170710Windows11_2_事件内核对象
- 洛谷 P2023 [AHOI2009]维护序列(bzoj P1798 [Ahoi2009]Seq 维护序列seq)
- 链表
- 《线性代数》学习笔记
- 自定义锚点
- Anaconda修改源与包管理
- 可自动换行的RadioGroupEx,支持RadioButton设置margin
- java基础--static和final的用法
- 第十天 filter过滤器
- 2017 上大校赛
- Linux下安装mysql
- 性能优化
- python学习(11)——模块