Open joelin109 opened 7 years ago
mapView.delegate = self
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);
Compare Mapbox & AutoNavi & Baidu iOS SDK
Download iOS SDK.
/ Step2. add 'Mapbox.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries)Download iOS SDK.
/ Step2.add 'AMapFoundationKit.framework, MAMapKit.framework, AMapLocationKit.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries)
Download iOS SDK.
/ Step2. add'BaiduMapAPI_**.framework' to Linked libraries. (TARGETS->Build Phases-> Link Binary With Libaries)
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)
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)
#import <AMapLocationKit/AMapLocationKit.h ,<MAMapKit/MAMapKit.h>, <AMapFoundationKit/AMapFoundationKit.h>
Get Default Public Token.
/ Step2.Add one key, "MGLMapboxAccessToken" in info.plist
Get a different key by project bundle Identifier.
/ Step2.Add codes about key in AppDelegate file
Get a different key by project bundle Identifier.
/ Step2.Add codes about key in AppDelegate file