ios 高德地图加载瓦片地图_集成iOS高德地图

一、前奏

这里只是个人集成过程中的遇到的点,现做下标记。

1,如果你需要集成涉及国外版地图,基于HTTPS的最新版本需要设置,需要注意基于国外定位,高德的不太精确(个人测试)

[self.mapView performSelector:@selector(setShowsWorldMap:) withObject:@(YES)];

这个方法后台提供的国外地图是第三方的,是不稳定的,不推荐使用。集成国外版地图详情见:http://lbs.amap.com/dev/demo/switch-map#iOS

2,坐标转换

//将GPS转成高德坐标

CLLocationCoordinate2D amapcoord = MACoordinateConvert(CLLocationCoordinate2DMake(39.989612,116.480972),MACoordinateTypeGPS);

二、实战

1,创建地图

#import

@property (nonatomic, strong)MAMapView *mapView; // 添加属性

// 添加到视图上

_mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];

_mapView.delegate = self;

[self.view addSubview:_mapView];

2,设置中心点

CLLocationCoordinate2D centerPoint = CLLocationCoordinate2DMake(30.2740850000,120.1550700000);//纬度,经度

self.mapView.centerCoordinate = centerPoint; // 或者[self.mapView setCenterCoordinate:(centerPoint) animated:YES];

3,隐藏指南针

_mapView.showsCompass = NO;

4,隐藏比例尺

_mapView.showsScale = NO;

5,手势控制

_mapView.zoomEnabled = YES;    // NO表示禁用缩放手势,YES表示开启

_mapView.scrollEnabled = YES;  // NO表示禁用滑动手势,YES表示开启

6,设置地图语言(默认中文)

_mapView.language = MAMapLanguageEn;

7,添加标注(大头针)

MAPointAnnotation *pointAnnotation1 = [[MAPointAnnotation alloc] init];

pointAnnotation1.coordinate = CLLocationCoordinate2DMake(39.907465,116.337447);

pointAnnotation1.title = @"木樨地";

pointAnnotation1.subtitle = @"北京市西城区复兴门外大街29号楼三里河路";

[_mapView addAnnotation:pointAnnotation]; // 单个添加,多个添加[_mapView addAnnotations:@[pointAnnotation,pointAnnotation1,pointAnnotation2]];

8,自定义标注(大头针)

- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation

{

if ([annotation isKindOfClass:[MAPointAnnotation class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值