美文网首页
高德地图

高德地图

作者: Dove_Q | 来源:发表于2016-09-01 20:08 被阅读9次

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)

相关文章

网友评论

      本文标题:高德地图

      本文链接:https://www.haomeiwen.com/subject/wrhhettx.html