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)
网友评论