Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >iOS百度地图开发之路径规划

iOS百度地图开发之路径规划

作者头像
hrscy
发布于 2018-08-30 04:18:23
发布于 2018-08-30 04:18:23
1.3K00
代码可运行
举报
文章被收录于专栏:hrscyhrscy
运行总次数:0
代码可运行

路线规划

示例程序

使用百度地图SDK版本为2.9.1。

需要将改

代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#import <MapKit/MapKit.h>
#import <BaiduMapAPI_Map/BMKMapView.h>
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Map/BMKPolylineView.h>
#import <BaiduMapAPI_Utils/BMKGeometry.h>
#import "HXRouteViewController.h"
#import "UIView+Extension.h"
#import "HXAnnotationView.h"
#import "HXAnnotation.h"
#import "HXMenDDetail.h"
#import "UIImage+Rotate.h"
#import "UIColor+HexString.h"
#import "FMActionSheet.h"
#import "ZoomInOrOutButton.h"

#define MYBUNDLE_NAME @ "mapapi.bundle"
#define MYBUNDLE_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: MYBUNDLE_NAME]
#define MYBUNDLE [NSBundle bundleWithPath: MYBUNDLE_PATH]

/**
 *  路线的标注
 */
@interface RouteAnnotation : BMKPointAnnotation
{
    int _type; ///<0:起点 1:终点 2:公交 3:地铁 4:驾乘 5:途经点
    int _degree;
}

@property (nonatomic) int type;
@property (nonatomic) int degree;
@end

@implementation RouteAnnotation

@synthesize type = _type;
@synthesize degree = _degree;
@end

@interface HXRouteViewController ()<BMKMapViewDelegate, BMKRouteSearchDelegate>{
    BMKMapView *_mapView;
    NSString *_cityName;
    BMKRouteSearch *_routesearch;
}

/**
 *  返回按钮
 */
//@property (nonatomic , weak)UIButton *preBtn;

/**
 *  存放标注数组
 */
@property(nonatomic , strong) NSMutableArray *annotations;

/**
 *  用户当前位置
 */
@property(nonatomic , strong) BMKUserLocation *userLocation;

@property(nonatomic , strong) HXAnnotation *anno;

@end

@implementation HXRouteViewController

- (NSString*)getMyBundlePath1:(NSString *)filename
{
    
    NSBundle * libBundle = MYBUNDLE ;
    if ( libBundle && filename ){
        NSString * s=[[libBundle resourcePath ] stringByAppendingPathComponent:filename];
        return s;
    }
    return nil ;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIView *statusView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENW, 20)];
    statusView.backgroundColor = [UIColor colorWithR:46 G:139 B:84 alpha:1.];
    [self.view addSubview:statusView];
    
    _routesearch = [[BMKRouteSearch alloc] init];
    _routesearch.delegate = self;
    
    //初始化BMKMapView并设置代理
    _mapView = [[BMKMapView alloc] initWithFrame:CGRectMake(0, 20, SCREENW, SCREENH - 140)];
    [self.view addSubview:_mapView];
    _mapView.delegate = self;
    
    _mapView.buildingsEnabled = YES;
    _mapView.overlookEnabled = YES;
    _mapView.showMapScaleBar = YES;
    _mapView.overlooking = -45;
    
    //设置放大/缩小按钮
    [self setupNavButton];
    //返回按钮
    [self backButton];
    //设置导航按钮
//    [self setupNavButton];
    //驾车路线
    [self showDriveSearch];
    //设置放大/缩小按钮
    [self setupZoomButton];
}

#pragma mark 设置放大/缩小按钮
-(void)setupZoomButton{
    ZoomInOrOutButton *zoomInOrOutBtn = [[[NSBundle mainBundle] loadNibNamed:@"ZoomInOrOutButton" owner:nil options:nil] lastObject];
    zoomInOrOutBtn.layer.cornerRadius = 5;
    
    zoomInOrOutBtn.x = SCREENW - 110;
    zoomInOrOutBtn.y = _mapView.height - 50;
    [_mapView addSubview:zoomInOrOutBtn];
    [zoomInOrOutBtn.zoomInBtn addTarget:self action:@selector(zoomInBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    zoomInOrOutBtn.zoomInBtn.tag = 0;
    [zoomInOrOutBtn.zoomOutBtn addTarget:self action:@selector(zoomInBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    zoomInOrOutBtn.zoomInBtn.tag = 1;
}

#pragma mark 点击放大按钮
-(void)zoomInBtnClick:(UIButton *)sender{
    _mapView.zoomLevel = sender.tag ? _mapView.zoomLevel++ : _mapView.zoomLevel--;
}

#pragma mark 返回按钮
-(void)backButton{
    
    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 30, 30, 40)];
    [backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    backButton.backgroundColor = [UIColor blackColor];
    backButton.layer.cornerRadius = 5;
    backButton.alpha = 0.7;
    [backButton bringSubviewToFront:_mapView];
    [backButton initSpringTouch];
    [self.view addSubview:backButton];
    [backButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark 返回
-(void)goBack{
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark 导航按钮
-(void)setupNavButton{
    
    UIView *bgView = [[UIView alloc] init];
    bgView.frame = CGRectMake(0, SCREENH - 120, SCREENW, 120);
    bgView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bgView];
    
    CGFloat viewX = 15;
    
    UILabel *shopLabel = [[UILabel alloc] initWithFrame:CGRectMake(viewX, 5, SCREENW - 30, 25)];
    shopLabel.text = [NSString stringWithFormat:@"门店名称:%@",self.mendDetail.shopName];
    shopLabel.textColor = [UIColor blackColor];
    shopLabel.font = [UIFont systemFontOfSize:15];
    [bgView addSubview:shopLabel];
    
    UILabel *addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(viewX, 30, SCREENW - 30, 25)];
    addressLabel.text = [NSString stringWithFormat:@"门店地址:%@",self.mendDetail.address];
    addressLabel.textColor = [UIColor lightGrayColor];
    addressLabel.font = [UIFont systemFontOfSize:14];
    [bgView addSubview:addressLabel];
    
    UIButton *navButton = [[UIButton alloc] init];
    navButton.frame = CGRectMake(15, 65, SCREENW - 30, 40);
    [navButton setTitle:@"导航" forState:UIControlStateNormal];
    [navButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navButton.layer setMasksToBounds:YES];
    [navButton.layer setCornerRadius:6];
    [navButton.layer setBorderWidth:1.0];
    [navButton initSpringTouch];
    //设置按钮的边界颜色
    CGColorRef color = [UIColor colorWithR:46 G:139 B:84 alpha:1.].CGColor;
    [navButton.layer setBorderColor:color];
    [navButton addTarget:self action:@selector(navButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:navButton];
}

#pragma mark弹出选择框
-(void)navButtonClick{
    //弹出框
    FMActionSheet *sheet = [[FMActionSheet alloc] initWithTitle:@"导航方式" buttonTitles:[NSArray arrayWithObjects:@"用手机自带地图导航", @"百度地图", nil] cancelButtonTitle:@"取消" delegate:(id<FMActionSheetDelegate>)self];
    sheet.tag = 103;
    sheet.titleFont = [UIFont systemFontOfSize:15];
    sheet.titleBackgroundColor = [UIColor colorWithHexString:@"f4f5f8"];
    sheet.titleColor = [UIColor colorWithHexString:@"666666"];
    sheet.lineColor = [UIColor colorWithHexString:@"dbdce4"];
    [sheet show];
    
}

- (void)actionSheet:(FMActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        //打开系统自带的地图
        [self openIOSMapNav];
    } else if (buttonIndex == 1) {
        //打开百度地图客户端导航
        [self opsenBaiduMap];
    }
}

#pragma mark 打开系统自带的地图
-(void)openIOSMapNav{
    CLLocationCoordinate2D endCoor = CLLocationCoordinate2DMake([self.mendDetail.dimensions doubleValue], [self.mendDetail.longitude doubleValue]);
    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:endCoor addressDictionary:nil]];
    toLocation.name = self.mendDetail.shopName;
    [MKMapItem openMapsWithItems:@[currentLocation, toLocation] launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];
}

-(void)opsenBaiduMap{
    double latitude =self.coordinate.latitude;
    double longitude =self.coordinate.longitude;
    NSString *urlString = [NSString stringWithFormat:@"baidumap://map/direction?origin=%f,%f&destination=%@,%@&mode=driving&region=北京",latitude,longitude,self.mendDetail.dimensions,self.mendDetail.longitude];
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *mapUrl = [NSURL URLWithString:urlString];
    if ([[UIApplication sharedApplication] canOpenURL:mapUrl]) {
        [[UIApplication sharedApplication] openURL:mapUrl];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您的手机没有安装百度地图" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alert show];
    }
    
}

- (UIColor *)actionSheet:(FMActionSheet *)actionSheet buttonTextColorAtIndex:(NSInteger)bottonIndex{
    UIColor *textColor = [UIColor colorWithR:41 G:140 B:82 alpha:1.];
    return textColor;
}

#pragma mark -显示大头针
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation{
    
    if (![annotation isKindOfClass:[RouteAnnotation class]]) return nil;
    return [self getRouteAnnotationView:mapView viewForAnnotation:(RouteAnnotation *)annotation];
}

#pragma mark 获取路线的标注,显示到地图
- (BMKAnnotationView*)getRouteAnnotationView:(BMKMapView *)mapview viewForAnnotation:(RouteAnnotation*)routeAnnotation{
    
    BMKAnnotationView *view = nil;
    switch (routeAnnotation.type) {
        case 0:
        {
            view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"start_node"];
            if (view == nil) {
                view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"start_node"];
                view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_start"]];
                view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
                view.canShowCallout = true;
            }
            view.annotation = routeAnnotation;
        }
            break;
        case 1:
        {
            view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"end_node"];
            if (view == nil) {
                view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"end_node"];
                view.image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_end"]];
                view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));
                view.canShowCallout = true;
            }
            view.annotation =routeAnnotation;
        }
            break;
        case 4:
        {
            view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"route_node"];
            if (view == nil) {
                view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"route_node"];
                view.canShowCallout = true;
            } else {
                [view setNeedsDisplay];
            }
            UIImage *image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_direction"]];
            view.image = [image imageRotatedByDegrees:routeAnnotation.degree];
            view.annotation = routeAnnotation;
        }
            break;
        default:
            break;
    }
    return view;
}

#pragma mark 驾车路线
-(void)showDriveSearch{
    //线路检索节点信息
    BMKPlanNode *start = [[BMKPlanNode alloc] init];
    start.pt = self.coordinate;
    start.cityName = @"北京市";
    BMKPlanNode *end = [[BMKPlanNode alloc] init];
    CLLocationCoordinate2D endCoordinate = CLLocationCoordinate2DMake([self.mendDetail.dimensions doubleValue], [self.mendDetail.longitude doubleValue]);
    end.pt = endCoordinate;
    end.cityName = @"北京市";
    BMKDrivingRoutePlanOption *drivingRouteSearchOption = [[BMKDrivingRoutePlanOption alloc] init];
    drivingRouteSearchOption.from = start;
    drivingRouteSearchOption.to = end;
    BOOL flag = [_routesearch drivingSearch:drivingRouteSearchOption];
    if (flag) {
    }
}

#pragma mark 返回驾乘搜索结果
- (void)onGetDrivingRouteResult:(BMKRouteSearch*)searcher result:(BMKDrivingRouteResult*)result errorCode:(BMKSearchErrorCode)error
{
    NSArray* array = [NSArray arrayWithArray:_mapView.annotations];
    [_mapView removeAnnotations:array];
    array = [NSArray arrayWithArray:_mapView.overlays];
    [_mapView removeOverlays:array];
    if (error == BMK_SEARCH_NO_ERROR) {
        //表示一条驾车路线
        BMKDrivingRouteLine* plan = (BMKDrivingRouteLine*)[result.routes objectAtIndex:0];
        // 计算路线方案中的路段数目
        int size = (int)[plan.steps count];
        int planPointCounts = 0;
        for (int i = 0; i < size; i++) {
            //表示驾车路线中的一个路段
            BMKDrivingStep* transitStep = [plan.steps objectAtIndex:i];
            if(i==0){
                RouteAnnotation* item = [[RouteAnnotation alloc]init];
                item.coordinate = plan.starting.location;
                item.title = @"起点";
                item.type = 0;
                [_mapView addAnnotation:item]; // 添加起点标注
                
            }else if(i==size-1){
                RouteAnnotation* item = [[RouteAnnotation alloc]init];
                item.coordinate = plan.terminal.location;
                item.title = @"终点";
                item.type = 1;
                [_mapView addAnnotation:item]; // 添加终点标注
            }
            //添加annotation节点
            RouteAnnotation* item = [[RouteAnnotation alloc]init];
            item.coordinate = transitStep.entrace.location;
            item.title = transitStep.entraceInstruction;
            item.degree = transitStep.direction * 30;
            item.type = 4;
            [_mapView addAnnotation:item];
            
            //轨迹点总数累计
            planPointCounts += transitStep.pointsCount;
        }
        // 添加途经点
        if (plan.wayPoints) {
            for (BMKPlanNode* tempNode in plan.wayPoints) {
                RouteAnnotation* item = [[RouteAnnotation alloc]init];
                item.coordinate = tempNode.pt;
                item.type = 5;
                item.title = tempNode.name;
                [_mapView addAnnotation:item];
            }
        }
        //轨迹点
        BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];
        int i = 0;
        for (int j = 0; j < size; j++) {
            BMKDrivingStep* transitStep = [plan.steps objectAtIndex:j];
            int k=0;
            for(k=0;k<transitStep.pointsCount;k++) {
                temppoints[i].x = transitStep.points[k].x;
                temppoints[i].y = transitStep.points[k].y;
                i++;
            }
            
        }
        // 通过points构建BMKPolyline
        BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];
        [_mapView addOverlay:polyLine]; // 添加路线overlay
        delete []temppoints;
        [self mapViewFitPolyLine:polyLine];
    }
}

#pragma mark 根据overlay生成对应的View
-(BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id<BMKOverlay>)overlay{
    if ([overlay isKindOfClass:[BMKPolyline class]]) {
        BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay];
        polylineView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:1];
        polylineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];
        polylineView.lineWidth = 3.0;
        return polylineView;
    }
    return nil;
}

#pragma mark  根据polyline设置地图范围
- (void)mapViewFitPolyLine:(BMKPolyline *) polyLine {
    CGFloat ltX, ltY, rbX, rbY;
    
    if (polyLine.pointCount < 1) return;
    BMKMapPoint pt = polyLine.points[0];
    ltX = pt.x, ltY = pt.y;
    rbX = pt.x, rbY = pt.y;
    
    for (int i = 0; i < polyLine.pointCount; i++) {
        BMKMapPoint pt = polyLine.points[i];
        if (pt.x < ltX) {
            ltX = pt.x;
        }
        if (pt.x > rbX) {
            rbX = pt.x;
        }
        if (pt.y > ltY) {
            ltY = pt.y;
        }
        if (pt.y < rbY) {
            rbY = pt.y;
        }
    }
    BMKMapRect rect;
    rect.origin = BMKMapPointMake(ltX , ltY);
    rect.size = BMKMapSizeMake(rbX - ltX, rbY - ltY);
    [_mapView setVisibleMapRect:rect];
    _mapView.zoomLevel = _mapView.zoomLevel - 0.3;
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [_mapView viewWillDisappear];
    _mapView.delegate = nil; // 不用时,置nil
    _routesearch.delegate = nil;
}

@end
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015.12.22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
iOS百度地图POI详情检索与路径规划(附Demo)
POI(Point of Interest)中文可以翻译为“兴趣点”。在地理信息系统中,一个POI可以是一栋房子、一个商铺、一个邮筒、一个公交站等。 写在前面:最近老是有朋友来问我这个检索怎么不行了,我今天看了下,果然,出了问题,似乎是百度地图的一个Bug。POI检索后调POI详情检索,但是详情检索出来的经纬度全部是0,这样自然是不能够成功添加大头针的。奇怪的是在POI检索中经纬度是有的,但是呢,详情中经纬度竟然丢失了。这个只能等百度那边修复了,当然我这里提供一个临时解决这个办法的方法。在文末我上
Raindew
2018/06/14
1.8K0
地图| 百度地图源码级使用大全
由于百度地图自带的BMKAnnotationView 中默认的是大头针,可以设置自定义图片(替换大头针),但是就是无法在地图上放置Label显示文字,本来想让所有大头针的气泡都默认弹出(设置 selected 就行),可是找不到一个方法使所有的气泡都弹出,最后只能自定义一个基于BMKAnnotationView的UIView
進无尽
2018/09/12
1.8K0
地图| 百度地图源码级使用大全
iOS地图找房(类似链家、安居客等地图找房)
题外话:在百度搜索键入:iOS地图找房。你会发现搜索到很多关于这方面的帖子,但是几乎都是询问如何实现的,找不到一个可以研究借鉴的博客。于是我决定补上这个空缺,写的可能不全面,大家体谅。 更新PS:原本
Raindew
2018/06/14
1.6K0
ios百度地图开发之显示标注
才能将annoView显示到地图上. 如果是自定义的paopaoView,BMKMapViewDelegate会有如下方法:
hrscy
2018/08/30
1.1K0
【IOS开发基础系列】地图开发专题
http://www.cnblogs.com/syxchina/archive/2012/10/14/2723522.html
江中散人_Jun
2023/10/16
4810
【IOS开发基础系列】地图开发专题
iOS百度地图开发中遇到的问题
由于项目需要地图功能,公司决定使用百度地图,但是百度地图也有很多问题,现在总结一下在百度地图中遇到的坑,希望给各位看官一点参考,避免走一些弯路.我使用的百度地图SDK2.9.1.
hrscy
2018/08/30
1K0
iOS百度地图开发中遇到的问题
iOS_系统自带地图圆形区域选择范围
5.聚集操作:删除原理的大头针,在新经纬度添加大头针,并将地图移动到新的经纬度(反地理编码获得位置信息)
mikimo
2022/07/20
2.4K0
iOS_系统自带地图圆形区域选择范围
iOS 百度地图 Demo
3.iOS 9 之后不能直接使用 HTTP 进行请求,需要在 Info.plist 新增一段用于控制 ATS 的配置:
hrscy
2018/08/30
1.2K0
iOS 百度地图 Demo
iOS原生地图开发进阶——使用导航和附近兴趣点检索
iOS中的mapKit框架对国际化的支持非常出色。在前些篇博客中,对这个地图框架的基础用法和标注与覆盖物的添加进行了详细的介绍,这篇博客将介绍两个更加实用的功能的开发:线路导航与兴趣点搜索。前几篇博客的链接如下:
珲少
2018/08/16
1K0
iOS原生地图开发进阶——使用导航和附近兴趣点检索
iOS百度地图问题总结(三)
如果想创建以静态图片作为大头针图片的话,可以通过创建MKAnnotationView是实例。如果想使用apple自带的大头针则创建MKPinAnnotationView.
hrscy
2018/08/30
1.2K0
iOS百度地图问题总结(三)
iOS百度地图问题总结(四)
下面这两个方法(void)mapView:(BMKMapView *)mapView didAddAnnotationViews:(NSArray *)views; 和
hrscy
2018/08/30
8960
iOS·采用第三方(百度地图SDK)实现定位等功能开发
首先,申请一个baidu账号,接着进入新建密钥入口申请成为baidu地图开发者,填写相关开发者信息和短信验证码。接下来点击创建应用,如官方文档新建密钥文档指南里面的截图所示,注意正确勾选有关项。如果你想要实名认证,点击页面右上角的实名状态,下面是该页面的截图。
陈满iOS
2018/09/10
2.2K0
iOS·采用第三方(百度地图SDK)实现定位等功能开发
地图相关 MapKit框架介绍MKMapView控件对象的属性和方法MKAnnotation 大头针模型类大头针view显示类:MKPinAnnotationView 继承于 MKAnnotation
介绍 1.概念 导入头文件 #import <MapKit/MapKit.h> MapKit框架中所有数据类型的前缀都是MK MapKit有一个比较重要的UI控件 :MKMapView,专门用于地图显
用户2141756
2018/05/18
5K0
iOS-自定义View的封装
xy_ss
2023/11/22
3370
iOS-自定义View的封装
地图| 高德地图源码级使用大全
高德地图提供包括:web前端、Android、iOS、服务器、小程序等平台的地图服务, 地图功能众多,本文记载的只是自己遇到的一些问题,绝大部分功能只要参照官方文档和Dome都可以实现出来。
進无尽
2018/09/12
4.6K0
地图| 高德地图源码级使用大全
demo1 动态显示view或弹框 动态隐藏view或弹框
实现界面如上所示: 有一个弹框,弹框上边有一个关闭按钮,点击按钮,可以关闭弹框。点击弹框的周围区域也可以关闭按钮。 点击上边的隐藏弹框也可以关闭按钮。 在实现功能的基础上,以动画的形式展示跟隐藏。 思路:在之前的开发中,我的思路比较局限。想着用一个view来做中间的那一块,那么问题来了,左上角的关闭按钮,就加在view的左上角。效果猛一看是可以实现,但是这个关闭按钮的点击事件,却不怎么好使,因为按钮有一部分超出了view的界限,于是,点击起来就不太好使。 遇见问题,解决问题。于是我就转换了一种思路
用户1219438
2018/02/01
1.1K0
demo1 动态显示view或弹框 动态隐藏view或弹框
iOS原生地图开发指南续——大头针与自定义标注
在上一篇博客中http://my.oschina.net/u/2340880/blog/415360系统总结了iOS原生地图框架MapKit中主体地图的设置与应用。这篇是上一篇的一个后续,总结了系统的大头针视图以及自定义标注视图的方法。
珲少
2018/08/16
1.2K0
iOS原生地图开发指南续——大头针与自定义标注
Objective-C MapKit的使用-LBS简单的租车主界面demo效果分析代码demo地址
https://github.com/gongxiaokai/EasyCarDemo
gwk_iOS
2018/08/23
2K0
Objective-C MapKit的使用-LBS简单的租车主界面demo效果分析代码demo地址
ios地图小例子和手势的使用 供大家参考一下呦
最近做了一个小例子 做点笔记 供刚入职场的菜鸟学习,也供自己记忆。 目标:在地图上加上标记  同时复习一下手势的使用 效果图: 具体代码 导入框架:MapKit.framework 创建一个新类 继承NSObject  叫做MyAnnotation   并在后边加上<MKAnnotation> #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface MyAnnotation : NSObject<MKAnnotation>
用户1219438
2018/02/01
8960
【IOS】IOS开发问题解决方法索引(六)
使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptablecontent-type: text/html 解决方法
江中散人_Jun
2022/03/08
9180
推荐阅读
相关推荐
iOS百度地图POI详情检索与路径规划(附Demo)
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验