joelin109 / blog

0 stars 0 forks source link

Compare the Mapbox & AutoNavi & Baidu iOS SDK #9

Open joelin109 opened 7 years ago

joelin109 commented 7 years ago

Compare Mapbox & AutoNavi & Baidu iOS SDK

Step Mapbox AutoNavi Baidu.Map
auto configuration pod 'Mapbox-iOS-SDK', ' 3.3.6' pod 'AMap3DMap', '4.3.0' pod 'AMapLocation', '~> 2.2.0' pod 'BaiduMapKit'
manual configuration step 1 Step1. Download iOS SDK. / Step2. add 'Mapbox.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries) Step1. Download iOS SDK. / Step2. add 'AMapFoundationKit.framework, MAMapKit.framework, AMapLocationKit.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries) Step1. Download iOS SDK. / Step2. add 'BaiduMapAPI_**.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries)
manual configuration step 2 Step3. add JavaScriptcore.framework, SystemConfiguration.framework, CoreTeleohony.framework, libz.tbd, libc++.tbd, libstdc++6.09.tbd, Security.framework to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries) Step3. add CoreLocation.framework, QuartzCore.framework、OpenGLES.framework , CoreGraphics.framework, CoreTeleohony.framework, libz.tbd, libc++.tbd, libstdc++6.09.tbd, Security.framework , SystemConfiguration.framework to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries) / Step4. add Files to project (BaiduMapAPI_Map.framework - Resources-mapapi.bundle)
add Bridging-Header.h #import <AMapLocationKit/AMapLocationKit.h ,<MAMapKit/MAMapKit.h>, <AMapFoundationKit/AMapFoundationKit.h> #import <BaiduMapAPI_Base/BMKBaseComponent.h>, <BaiduMapAPI_Map/BMKMapComponent.h>, <BaiduMapAPI_Location/BMKLocationComponent.h>, <BaiduMapAPI_Utils/BMKUtilsComponent.h>, <BaiduMapAPI_Map/BMKMapView.h>
Add Keys
APIKey/Token Step1. Get Default Public Token. / Step2. Add one key, "MGLMapboxAccessToken" in info.plist Step1. Get a different key by project bundle Identifier. / Step2. Add codes about key in AppDelegate file Step1. Get a different key by project bundle Identifier. / Step2. Add codes about key in AppDelegate file
others Add keys, 'NSLocationAlwaysUsageDescription' and 'NSLocationWhenInUseUsageDescription' in info.plist Add keys, 'NSLocationAlwaysUsageDescription' and 'NSLocationWhenInUseUsageDescription' and "NSAppTransportSecurity" in info.plist Add keys, 'NSLocationAlwaysUsageDescription' and 'NSLocationWhenInUseUsageDescription' and "NSAppTransportSecurity" in info.plist

joelin109 commented 7 years ago

Compare Code Part

Mapbox

mapView.zoomLevel = 13 mapView.centerCoordinate = ???; mapView.styleURL = MGLStyle.outdoorsStyleURL(withVersion: 9);


- show user location

mapView.userTrackingMode = .follow


- add bubble pin

let point = MGLPointAnnotation() point.coordinate = CLLocationCoordinate2D(latitude: 31.2295, longitude: 121.44) point.title = "MapBox" point.subtitle = "Demo - test only for Joe"

mapView.addAnnotation(point)


 ## AutoNavi
- basic mapview

var mapView = MAMapView(frame: self.view.bounds) mapView.delegate = self

mapView.zoomLevel = 13 mapView.centerCoordinate = ???; //mapView.styleURL = MGLStyle.outdoorsStyleURL(withVersion: 9);


- show user location

mapView.userTrackingMode = MAUserTrackingMode.follow


- add bubble pin

let point = MAPointAnnotation() point.coordinate = CLLocationCoordinate2D(latitude: 31.2295, longitude: 121.44); point.title = "IMap - AutoNavi" point.subtitle = "Demo - test only for Joe" mapView.addAnnotation(point)

func mapView(_ mapView: MAMapView!, viewFor annotation: MAAnnotation!) -> MAAnnotationView! { if(annotation.isKind(of: MAPointAnnotation.self) ) { let tag = "1234567890"; var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: tag); if(annotationView == nil) { annotationView = MAPinAnnotationView(annotation: annotation, reuseIdentifier: tag) annotationView?.canShowCallout = true; } return annotationView; } else{ return nil } }


 ## Baidu Map
- basic mapview

let mapView = BMKMapView(frame: UIScreen.main.bounds) mapView.delegate = self mapView.zoomLevel = 13 mapView.centerCoordinate = ???;

func didUpdate(_ userLocation: BMKUserLocation!) { mapView.updateLocationData(userLocation) let viewRegion = BMKCoordinateRegionMake(userLocation.location.coordinate, BMKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03)) let region = mapView.regionThatFits(viewRegion) mapView.setRegion(region, animated: true) }


- show user location

let service = BMKLocationService() service.delegate = self service.startUserLocationService()

mapView.showsUserLocation = true;


- add bubble pin

let annotation: BMKPointAnnotation = BMKPointAnnotation(); annotation.coordinate = CLLocationCoordinate2DMake(31.2295, 121.44); annotation.title = "Baidu Map"; annotation.subtitle = "Demo - test only for Joe"; mapView.addAnnotation(annotation);

joelin109 commented 7 years ago

Compare Map Pic

img_0023

img_0022

img_0021