{"rsdb":{"rid":"180129","subhead":"","postdate":"0","aid":"130621","fid":"89","uid":"1","topic":"1","content":"
\n

\u63a5\u4e0a\u4e00\u7247\u535a\u6587,\u6211\u4eec\u5df2\u7ecf\u521b\u5efa\u597d\u4e86\u6865\u63a5\u6587\u4ef6.\u90a3\u4e48\u5982\u4f55\u8c03\u7528?<\/p> \n

\u5728\u9879\u76ee\u6700\u5f00\u59cb\u7684\u65f6\u5019,\u6211\u5199\u4e86\u8fd9\u4e2a\u9879\u76ee\u4f7f\u7528cocoapod\u7ba1\u7406\u4f9d\u8d56\u5e93,\u5728\u8fd9\u91cc,\u8fd8\u662f\u591a\u8bb0\u5f55\u4e00\u4e0b\u5427.<\/p> \n

1 \u5728\u4f60\u7684\u5df2\u7ecf\u5b89\u88c5\u597dcocoapod\u7684\u7535\u8111\u4e0a,\u6253\u5f00\u7ec8\u7aef,\u8f93\u5165pod search baidumapapi ,\u5f97\u5230\u7684\u7ed3\u679c\u5982\u4e0b:<\/p> \n

\"\"<\/p> \n

\u526a\u5934\u4e2d\u7684\u5c31\u662f\u6211\u4eec\u9700\u8981\u7684,\u7136\u540e\u5728\u6211\u4eec\u7684\u9879\u76ee\u4e2d\u7684podfile\u4e2d\u628apod 'BaiduMapAPI' '~>2.8.1'\u52a0\u8fdb\u53bb\u5e76\u4e14\u4fdd\u5b58<\/p> \n

2 \u52a0\u597d\u4e86\u7c7b\u5e93\u5f53\u7136\u9700\u8981\u5b89\u88c5\u5230\u9879\u76ee\u4e2d,\u6240\u4ee5\u8f93\u5165pod install,\u7b49\u5f85\u5b89\u88c5\u5b8c\u6bd5<\/p> \n

3 \u91cd\u65b0\u6253\u5f00\u9879\u76ee,\u53d1\u73b0\u9879\u76ee\u7ed3\u6784\u53d8\u6210\u5982\u4e0b\u6a21\u6837:<\/p> \n

  \"\"<\/p> \n

 \u7136\u540e\u6253\u5f00\u6211\u4eec\u7684\u6865\u63a5\u6587\u4ef6,\u5f15\u7528\u767e\u5ea6\u5730\u56fe\u7684\u5934\u6587\u4ef6<\/p> \n

 \"\"<\/p> \n

command + B \u8bd5\u8bd5\u662f\u5426\u7f16\u8bd1\u6210\u529f,\u6210\u529f\u5c31\u53ef\u8fdb\u884c\u4e0b\u4e00\u6b65\u4e86.<\/p> \n

4 \u672c\u6765\u9879\u76ee\u5f00\u59cb\u5e94\u8be5\u8fdb\u5165\u7684\u662f\u9996\u9875,\u4f46\u662f\u4e0a\u9762\u65e2\u7136\u5199\u4e86\u5982\u4f55\u4f7f\u7528\u767e\u5ea6\u5730\u56feAPI,\u90a3\u4e48\u5c31\u76f4\u63a5\u5199\u5728\u8fd9\u91cc,\u540e\u9762\u5199\u5230\u4f7f\u7528\u767e\u5ea6\u5730\u56fe\u7684\u9875\u9762\u5c31\u4e0d\u5199\u4e86..<\/p> \n

   \u4ee3\u7801\u5982\u4e0b:<\/p> \n

   \u2460 \u9996\u5148\u5728appdelegate\u91cc\u6dfb\u52a0\u7ea2\u8272\u6846\u6846\u91cc\u7684\u4ee3\u7801,\u91cc\u9762\u526a\u5934\u90e8\u5206\u9700\u8981\u4f60\u5230\u767e\u5ea6\u5b98\u7f51\u62ff\u9879\u76ee\u7684bundle identify\u6765\u751f\u6210\u4e00\u4e2akey,\u4e0d\u8981\u6309\u7167\u6211\u8fd9\u4e2a\u5199\u554a<\/p> \n

       \"\"<\/p> \n

    \u2461  \u7136\u540e\u5728\u63a7\u5236\u5668\u91cc\u4ee3\u7801\u5982\u4e0b:<\/p> \n

\u3000\u3000     <\/p> \n

import UIKit<\/p> \n

 <\/p> \n

class ViewController: UIViewController ,BMKMapViewDelegate ,BMKLocationServiceDelegate{<\/p> \n

    <\/p> \n

    var mapView: BMKMapView!<\/p> \n

    var locService: BMKLocationService!<\/p> \n

    <\/p> \n

    override func viewDidLoad() {<\/p> \n

        super.viewDidLoad()<\/p> \n

        \/\/ Do any additional setup after loading the view, typically from a nib.<\/p> \n

        mapView = BMKMapView(frame: self.view.frame)  \/\/\u521b\u5efa\u5730\u56fe\u7684view<\/p> \n

        self.view = mapView   \/\/\u8ba9\u767e\u5ea6\u5730\u56fe\u7684view\u6210\u4e3a\u63a7\u5236\u5668\u7684view<\/p> \n

        <\/p> \n

        \/\/\u8bbe\u7f6e\u5b9a\u4f4d\u7cbe\u51c6\u5ea6<\/p> \n

        BMKLocationService.setLocationDesiredAccuracy(kCLLocationAccuracyBest)<\/p> \n

        \/\/\u6307\u5b9a\u6700\u5c0f\u8ddd\u79bb\u66f4\u65b0,\u5355\u4f4d\u662f\u7c73<\/p> \n

        BMKLocationService.setLocationDistanceFilter(10)<\/p> \n

        <\/p> \n

        \/\/\u521d\u59cb\u5316\u5b9a\u4f4d\u670d\u52a1<\/p> \n

        locService = BMKLocationService()<\/p> \n

        \/\/\u542f\u52a8\u5b9a\u4f4d\u670d\u52a1<\/p> \n

        locService .startUserLocationService()<\/p> \n

        <\/p> \n

        mapView.showsUserLocation = false<\/p> \n

        \/\/\u8bbe\u7f6e\u4f4d\u7f6e\u8ddf\u8e2a\u6001<\/p> \n

        mapView.userTrackingMode = BMKUserTrackingModeNone<\/p> \n

        \/\/\u663e\u793a\u5b9a\u4f4d\u56fe\u5c42<\/p> \n

        mapView.showsUserLocation = true<\/p> \n

        \/\/\u8bbe\u7f6e\u662f\u5426\u652f\u6301\u591a\u70b9(\u7f29\u653e)<\/p> \n

        mapView .zoomEnabled = true<\/p> \n

        \/\/\u624b\u673a\u6bd4\u4f8b\u5c3a\u4e2d\u53ef\u4ee5\u663e\u793a\u7684\u7ea7\u522b  \u6700\u9ad8\u4e3a19<\/p> \n

        mapView .zoomLevel = 19<\/p> \n

    }<\/p> \n

    <\/p> \n

    \/\/\u5b9a\u4f4d\u4ee3\u7406<\/p> \n

    \/\/\u7528\u6237\u65b9\u5411\u66f4\u6539\u540e<\/p> \n

    func didUpdateUserHeading(userLocation: BMKUserLocation!) {<\/p> \n

        mapView.updateLocationData(userLocation)<\/p> \n

    }<\/p> \n

    <\/p> \n

    \/\/\u4f4d\u7f6e\u66f4\u65b0\u540e<\/p> \n

    func didUpdateBMKUserLocation(userLocation: BMKUserLocation!) {<\/p> \n

        mapView.updateLocationData(userLocation)<\/p> \n

        \/\/\u79fb\u52a8\u5b9a\u4f4d\u7684\u4f4d\u7f6e\u5230\u5c4f\u5e55\u4e2d\u95f4<\/p> \n

        mapView .setCenterCoordinate(userLocation.location.coordinate, animated: true)<\/p> \n

    }<\/p> \n

    <\/p> \n

    override func viewWillAppear(animated: Bool) {<\/p> \n

        mapView.viewWillAppear()<\/p> \n

        mapView.delegate = self   \/\/\u5728\u63a7\u5236\u5668view\u5c06\u8981\u663e\u793a\u7684\u65f6\u5019\u8bbe\u7f6emapview\u4ee5\u53ca\u5b9a\u4f4d\u7684Locservice\u7684\u4ee3\u7406\u4e3a\u63a7\u5236\u5668<\/p> \n

        locService.delegate = self<\/p> \n

    }<\/p> \n

    <\/p> \n

    override func viewWillDisappear(anim","orderid":"0","title":"\u7528Swift\u91cd\u5199\u516c\u53f8OC\u9879\u76ee(Day2--swift\u5982\u4f55\u8c03\u7528OC\u7c7b\u5e93,swift\u5f00\u53d1\u4e4b\u767e\u5ea6\u5730\u56fe\u7684\u96c6\u6210\u4ee5\u53ca\u5982\u4f55\u5173\u95edATS)(\u4e00)","smalltitle":"","mid":"0","fname":"Swift","special_id":"0","bak_id":"0","info":"0","hits":"6929","pages":"2","comments":"0","posttime":"2017-10-10 12:18:51","list":"1507609131","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/article\/89\/1_xw5hi__.png","ispic":"1","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Swift<\/A> \u91cd\u5199<\/A> \u516c\u53f8<\/A> \u9879\u76ee<\/A> Day2--swift<\/A> \u5982\u4f55<\/A> \u8c03\u7528<\/A> \u7c7b\u5e93<\/A> swift<\/A> \u5f00\u53d1<\/A> \u767e\u5ea6<\/A> \u5730\u56fe<\/A> \u96c6\u6210<\/A> \u4ee5\u53ca<\/A> \u5173\u95ed<\/A> ATS<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.108.110.181","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u7528Swift\u91cd\u5199\u516c\u53f8OC\u9879\u76ee(Day2--swift\u5982\u4f55\u8c03\u7528OC\u7c7b\u5e93,swift\u5f00\u53d1\u4e4b\u767e\u5ea6\u5730\u56fe\u7684\u96c6\u6210\u4ee5\u53ca\u5982\u4f55\u5173\u95edATS)","lastview":"1713421514","digg_num":"6661","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}