美文网首页
ios高德地图的一些简单使用

ios高德地图的一些简单使用

作者: BLMamba | 来源:发表于2018-01-30 13:51 被阅读0次

一.自定义当前位置图标,并且随着手机方向的变化箭头指向做出相对应的变动  

样式如下图:

图一(手机竖着) 图二(手机横着)

遵守 MAMapViewDelegate 代理 ,主要代码如下

#pragma mark 箭头方向

- (void)mapView:(MAMapView *)mapView didAddAnnotationViews:(NSArray *)views{

    MAAnnotationView *view = views[0];

    // 放到该方法中用以保证userlocation的annotationView已经添加到地图上了。

    if ([view.annotation isKindOfClass:[MAUserLocation class]])

    {

        MAUserLocationRepresentation *pre = [[MAUserLocationRepresentation alloc] init];

        //        pre.fillColor = [UIColor colorWithRed:0.0 green:0.0 blue:255 alpha:0.1];

        //        pre.strokeColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.9 alpha:1.0];

        pre.image = [UIImage imageNamed:@"NowLocal"];//自定义当前位置的图片

        //        pre.lineWidth = 2;

        //        pre.lineDashPattern = @[@6, @3];

        [self.mapView updateUserLocationRepresentation:pre];

        view.calloutOffset = CGPointMake(0, 0);

        view.canShowCallout = YES;

        self.userLocationAnnotationView = view;

    }

}

/**

* @brief 位置或者设备方向更新后,会调用此函数

* @param mapView 地图View

* @param userLocation 用户定位信息(包括位置与设备方向等数据)

* @param updatingLocation 标示是否是location数据更新, YES:location数据更新 NO:heading数据更新

*/

- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation{

    if (!updatingLocation && self.userLocationAnnotationView != nil)

    {

        [UIView animateWithDuration:0.1 animations:^{

            double degree = userLocation.heading.trueHeading;

            self.userLocationAnnotationView.transform = CGAffineTransformMakeRotation(degree * M_PI / 180.f );

        }];

    }

}


二. 添加自定义样式点标记、添加自定义气泡

1.添加自定义样式点标记  如下图:

自定义标记点

2. 添加自定义气泡  如下图:

自定义气泡 

#pragma mark 添加自定义样式点标记

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

    if ([annotation isMemberOfClass:[MAUserLocation class]]) {

        return nil;

    }

    if ([annotation isKindOfClass:[MAPointAnnotation class]]){

        static NSString *customReuseIndetifier = @"customReuseIndetifier";

//CustomAnnotationView 自定义标记点的类   github下载地址:https://github.com/c103363/CustomAnnotationView.git

        CustomAnnotationView *annotationView = (CustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:customReuseIndetifier];

        if (annotationView == nil){

            annotationView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:customReuseIndetifier];

            annotationView.canShowCallout = NO;

            annotationView.draggable = YES;

            annotationView.calloutOffset = CGPointMake(0, -5);

        }

        annotationView.portrait = [UIImage imageNamed:@"定位"];

annotationView.nameLabel.text = annotation.subtitle;

        return annotationView;

    }

    return nil;

}

相关文章

  • iOS地图导航功能实现

    最简单快捷的方法使用高德地图uri,高德地图uri的具体使用可在高德地图官方网站看,使用非常简单 简单贴下部分代码...

  • iOS 使用高德地图正确姿势(三)

    iOS 使用高德地图正确姿势(一)iOS 使用高德地图正确姿势(二) 实现大头针始终在地图中心,拖动地图实时poi...

  • iOS 高德地图的使用

    iOS:高德地图的使用 本人花了点时间集成了高德地图的几乎所有的功能,包含:地图的显示、地图的绘制、地图的定位、地...

  • ios高德地图的一些简单使用

    一.自定义当前位置图标,并且随着手机方向的变化箭头指向做出相对应的变动 样式如下图: 遵守MAMapViewDe...

  • iOS 高德地图开发详解

    iOS 高德地图开发详解

  • iOS 高德地图 经纬度转view坐标 view坐标转经

    iOS 高德地图 经纬度转view坐标 view坐标转经纬度对于这两个方法,高德地图,有封装好的方法 使用...

  • RN-地图导航

    调起百度网页地图路径导航 调起高德网页地图路径导航 iOS调起百度APP地图路径导航 iOS调起高德app地图路径...

  • 玩玩Flutter Web —— 实现高德地图插件

    1.啰嗦几句 去年写了一个功能简单的高德地图插件给flutter_deer使用,当时支持了Android与iOS两...

  • 高德地图的简单使用

    最简单的高德地图2D地图的使用,仅包含了添加Marker,拖动Marker后转换经纬度到详细地址并显示。混淆时注意加上:

  • swift原生地图与高德地图

    可以使用原生地图,也可以使用高德地图或者其他,高德开发者网站会教你如何在各个平台使用高德地图。 原生地图 记得im...

网友评论

      本文标题:ios高德地图的一些简单使用

      本文链接:https://www.haomeiwen.com/subject/ykqczxtx.html