高德地图

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)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容