高德地圖

cocoaPods

#import <AMapSearchKit/AMapSearchKit.h>
#import <MAMapKit/MAMapKit.h>
AppDelegate
        (MAMapServices)AMapServices.sharedServices().apiKey = "1221e4f2247ac552892dd8d5f3146cb4"

ViewController

func initMapView(){
        
        let compassX = mapView?.compassOrigin.x
        
        let scaleX = mapView?.scaleOrigin.x
        
        //設置指南針和比例尺的位置
        
        mapView?.compassOrigin = CGPointMake(compassX!,21)
        
        mapView?.scaleOrigin = CGPointMake(scaleX!,21)
        
        mapView = MAMapView(frame:self.view.bounds)
        
        self.view.addSubview(mapView!)
        
        self.view.sendSubviewToBack(mapView!)
        
        mapView!.showsUserLocation = true//開啟定位
        
    
        mapView?.allowsBackgroundLocationUpdates = true
        
        
        mapView?.userTrackingMode = .Follow
        mapView!.distanceFilter = 500.0
        
        mapView!.desiredAccuracy=kCLLocationAccuracyBestForNavigation
    }

Framework

注意: 要加 liz.tbd 和 libstdc++.6.0.9.tbd
info.plist: NSLocationAlwaysUsageDescription

let mapView = MAMapView(frame: self.view.bounds)
        //衛星地圖
//        mapView.mapType = .Satellite
        mapView.showsUserLocation = true
        mapView.userTrackingMode = .Follow
        mapView.delegate = self
        self.view.addSubview(mapView)
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容