美文网首页
ios 高德地图小蓝点于标记冲突

ios 高德地图小蓝点于标记冲突

作者: SSSDDDDKKK | 来源:发表于2017-08-02 11:03 被阅读0次

    公司项目要求用高德地图

    在开发到标记的时候莫名其妙的发现小圆点也变成标记了

    http://lbs.amap.com/api/ios-sdk/guide/create-map/location-map

    注意:5.1.0后由于定位蓝点增加了平滑移动功能,如果在开启定位的情况下先添加annotation,需要在此回调方法中判断annotation是否为MAUserLocation,从而返回正确的View。注释如下:

    /**

    * @brief 根据anntation生成对应的View。

    注意:5.1.0后由于定位蓝点增加了平滑移动功能,如果在开启定位的情况先添加annotation,需要在此回调方法中判断annotation是否为MAUserLocation,从而返回正确的View。

    if([annotationisKindOfClass:[MAUserLocationclass]]) {

    returnnil;

    }

    * @param mapView 地图View

    * @param annotation 指定的标注

    * @return生成的标注View

    */

    就是:

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

    {

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

    return nil;

    }

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

    {

    static NSString *pointReuseIndentifier = @"pointReuseIndentifier";

    MAPinAnnotationView*annotationView = (MAPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndentifier];

    if (annotationView == nil)

    {

    annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndentifier];

    }

    annotationView.canShowCallout= YES;      //设置气泡可以弹出,默认为NO

    annotationView.animatesDrop = YES;        //设置标注动画显示,默认为NO

    annotationView.draggable = YES;          //设置标注可以拖动,默认为NO

    annotationView.pinColor = MAPinAnnotationColorRed;

    return annotationView;

    }

    return nil;

    }

    相关文章

      网友评论

          本文标题:ios 高德地图小蓝点于标记冲突

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