随笔 - 400,  文章 - 0,  评论 - 7,  阅读 - 21万

 

 

1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关所有的头文件
 
#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
 
#import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入检索功能所有的头文件
 
#import <BaiduMapAPI_Cloud/BMKCloudSearchComponent.h>//引入云检索功能所有的头文件
 
#import <BaiduMapAPI_Location/BMKLocationComponent.h>//引入定位功能所有的头文件
 
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>//引入计算工具所有的头文件
 
#import <BaiduMapAPI_Radar/BMKRadarComponent.h>//引入周边雷达功能所有的头文件
 
#import <BaiduMapAPI_Map/BMKMapView.h>//只引入所需的单个头文件

  

2.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import Foundation
 
typealias POIResultBlock = ([BMKPoiInfo])->()
 
class BaiduTool: NSObject {
 
    static let shareInstance = BaiduTool()
     
     
    private lazy var searcher: BMKPoiSearch = {
         
        let searcher = BMKPoiSearch()
        searcher.delegate = self
        return searcher
         
    }()
     
    private var poiResultBlock: POIResultBlock?
     
     
    func beginNav(startCoordinate: CLLocationCoordinate2D, endCoordinate: CLLocationCoordinate2D) {
        //节点数组
        var nodesArray = [BNRoutePlanNode]()
        //起点
        let startNode = BNRoutePlanNode()
        startNode.pos = BNPosition()
        startNode.pos.x = startCoordinate.longitude;
        startNode.pos.y = startCoordinate.latitude;
        startNode.pos.eType = BNCoordinate_BaiduMapSDK;
        nodesArray.append(startNode)
         
        //终点
        let endNode = BNRoutePlanNode()
        endNode.pos = BNPosition()
        endNode.pos.x = endCoordinate.longitude
        endNode.pos.y = endCoordinate.latitude
        endNode.pos.eType = BNCoordinate_BaiduMapSDK;
        nodesArray.append(endNode)
         
        BNCoreServices.RoutePlanService().startNaviRoutePlan(BNRoutePlanMode_Recommend, naviNodes: nodesArray, time: nil, delegete: self  , userInfo: nil)
    }
     
     
    class func addAnnotation(coordinate: CLLocationCoordinate2D, title: String, subtitle: String, toMapView: BMKMapView) {
//        添加一个PointAnnotation
        let annotation = BMKPointAnnotation()
        annotation.coordinate = coordinate
        annotation.title = title
        annotation.subtitle = subtitle
         
        toMapView.addAnnotation(annotation)
 
    }
     
     
    func getPOIInfos(keyWord: String, center: CLLocationCoordinate2D, result: POIResultBlock?) {
         
        // 记录代码块, 在合适的地方执行
        poiResultBlock = result
         
         
        // poi检索
         
        //发起检索
        let option = BMKNearbySearchOption()
        // 起始页码
        option.pageIndex = 0
        // 每一页的容量
        option.pageCapacity = 20
        // 周边检索(谁的周边,中心店)
        // CLLocationCoordinate2DMake(39.915, 116.404)
        option.location = center
        option.keyword = keyWord
         
        let flag = searcher.poiSearchNearBy(option)
         
        if flag
        {
            print("周边检索发送成功")
        }
        else
        {
            print("周边检索发送失败")
        }
         
 
         
    }
     
}
 
 
 
extension BaiduTool: BMKPoiSearchDelegate {
     
    func onGetPoiResult(searcher: BMKPoiSearch!, result poiResult: BMKPoiResult!, errorCode: BMKSearchErrorCode) {
         
        if errorCode == BMK_SEARCH_NO_ERROR {
            print("周边检索成功")
            print(poiResult.poiInfoList)
             
            let poiInfos = poiResult.poiInfoList as! [BMKPoiInfo]
             
            if poiResultBlock != nil {
                poiResultBlock!(poiInfos)
            }
        
             
        }else {
            print("检索失败")
        }
         
    }
 
     
}
 
 
extension BaiduTool: BNNaviRoutePlanDelegate {
     
    func routePlanDidFinished(userInfo: [NSObject : AnyObject]!) {
        BNCoreServices.UIService().showNaviUI(BN_NaviTypeSimulator, delegete: nil , isNeedLandscape: false)
    }
     
     
     
     
}

  

posted on   懂事长qingzZ  阅读(189)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示