BaiduMapOnlyPOI
支持 CocoaPods。将以下配置添加到 Podfile
pod 'BaiduMapOnlyPOI', '~> 2.7.1'
检索功能:包括POI检索,地点详情检索,公交信息查询,路线规划,地理编码/反地理编码,在线建议查询,短串分享等;
BaiduMapOnlyPOI
允许用户通过CoreLocation获取坐标,然后使用Baidu地图获取反向信息
BaiduMapOnlyPOI
支持 Swift
BaiduMapOnlyPOI
支持 虚拟机 & 真机,提交流审时请使用真机 framework
在 AppDelegate.swift
中添加:
let baiduManager:BMKMapManager = BMKMapManager()
var ret:Bool = baiduManager.start("your_key", generalDelegate: nil)
if (!ret) {
println("manager start failed!")
}else{
println("manager start succ!")
}
在 your_class.swift
中添加
class YourLocationClass: NSObject,CLLocationManagerDelegate,BMKGeoCodeSearchDelegate{
let locationManager:CLLocationManager = CLLocationManager()
let searcher:BMKGeoCodeSearch = BMKGeoCodeSearch()
override init(){
super.init()
locationManager.delegate = self
searcher.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLLocationAccuracyThreeKilometers
if is_ios8() {
locationManager.requestAlwaysAuthorization()
}
locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!){
self.locationManager.stopUpdatingLocation();
var location:CLLocation = locations.last as! CLLocation
if location.horizontalAccuracy > 0 {
var pt:CLLocationCoordinate2D = location.coordinate
var reverseGeoCodeSearchOption:BMKReverseGeoCodeOption = BMKReverseGeoCodeOption.alloc()
reverseGeoCodeSearchOption.reverseGeoPoint = pt
var flag:Bool = searcher.reverseGeoCode(reverseGeoCodeSearchOption)
if(flag)
{
println("反geo检索发送成功");
}
else
{
println("反geo检索发送失败");
}
}
}
回调:
func onGetReverseGeoCodeResult(searcher:BMKGeoCodeSearch,#result:BMKReverseGeoCodeResult,errorCode error:BMKSearchErrorCode){
if error.value == 0 {
let addr = result.addressDetail
self.city_name = addr.city
self.district = addr.district
self.province = addr.province
}else {
println("抱歉,未找到结果")
}
}
感谢 qzs21。原始项目由 qzs21/BaiduMapAPI 分叉。
检索功能
1. 开放驾车线路规划,返回多条线路的能力:
BMKDrivingRouteResult中,routes数组有多条数据,支持检索结果为多条线路
2. 驾车线路规划结果中,新增路况信息字段:
BMKDrivingRoutePlanOption新增属性:
///驾车检索获取路线每一个step的路况,默认使用BMK_DRIVING_REQUEST_TRAFFICE_TYPE_NONE
@property (nonatomic) BMKDrivingRequestTrafficType drivingRequestTrafficType;
BMKDrivingStep新增属性:
///路段是否有路况信息
@property (nonatomic) BOOL hasTrafficsInfo;
///路段的路况信息,成员为NSNumber。0:无数据;1:畅通;2:缓慢;3:拥堵
@property (nonatomic, strong) NSArray* traffics;
3.废弃接口:
BMKDrivingRouteLine中,废弃属性:isSupportTraffic