在做專案整合百度地圖SDK時,配置開發環境時,可以下載全新.framework形式靜態庫,傳統.a形式靜態庫,在用.a形式靜態庫時在第二步需要引入靜態庫檔案 ,由於有模擬器和真機兩個靜態庫,整合文件寫了三種引入,第二種需要講兩個靜態庫合併,整合文件寫的也很清楚,自己也算是比照著整合文件按部就班的操作就可以了。具體請參考:http://developer.baidu.com/map/index.php?title=iossdk 在這我也就是操作記錄一下。下面是.a 靜態庫的合併
下面是framework的合併 兩者區別:.a是生成到一個新.a .framework的生成時覆蓋舊的
// // ViewController.m // baiDuDemo // // Created by City--Online on 15/5/26. // Copyright (c) 2015年 XQB. All rights reserved. // #import "ViewController.h" #import "BMKMapView.h" #import "BMapKit.h" @interface ViewController ()<BMKMapViewDelegate> @property(nonatomic,strong)BMKMapView *mapView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _mapView=[[BMKMapView alloc]initWithFrame:self.view.bounds]; //地圖型別 _mapView.mapType=BMKMapTypeStandard; //實時路況 // _mapView.trafficEnabled=YES; //城市熱力圖 // _mapView.baiduHeatMapEnabled=YES; // CLLocationCoordinate2D coor; coor.latitude=22.5538; coor.longitude=114.0672; //設定中心點 _mapView.centerCoordinate=coor; // 新增折線覆蓋物 CLLocationCoordinate2D coors[2] = {0}; coors[0].latitude = 22.7538; coors[0].longitude = 114.0672; coors[1].latitude = 23.0538; coors[1].longitude = 114.2672; BMKPolyline* polyline = [BMKPolyline polylineWithCoordinates:coors count:2]; [_mapView addOverlay:polyline]; //新增弧線覆蓋物 //傳入的座標順序為起點、途經點、終點 CLLocationCoordinate2D coords[3] = {0}; coords[0].latitude = 22.7538; coords[0].longitude = 114.0672; coords[1].latitude = 22.3538; coords[1].longitude = 114.2672; coords[2].latitude = 22.0538; coords[2].longitude = 114.2872; BMKArcline *arcline = [BMKArcline arclineWithCoordinates:coords]; [_mapView addOverlay:arcline]; // 新增多邊形覆蓋物 CLLocationCoordinate2D coorss[3] = {0}; coorss[0].latitude = 22.7538; coorss[0].longitude = 114.0672; coorss[1].latitude = 22.3538; coorss[1].longitude = 114.2672; coorss[2].latitude = 22.0538; coorss[2].longitude = 114.2872; BMKPolygon* polygon = [BMKPolygon polygonWithCoordinates:coorss count:3]; [_mapView addOverlay:polygon]; // 新增圓形覆蓋物 CLLocationCoordinate2D coorcircle; coorcircle.latitude = 22.5538; coorcircle.longitude = 114.0672; BMKCircle* circle = [BMKCircle circleWithCenterCoordinate:coorcircle radius:5000]; [_mapView addOverlay:circle]; //新增圖片圖層覆蓋物(第一種:根據指定經緯度座標生成) CLLocationCoordinate2D coorground; coorground.latitude = 22.0038; coorground.longitude = 114.0672; BMKGroundOverlay* ground = [BMKGroundOverlay groundOverlayWithPosition:coorground zoomLevel:11 anchor:CGPointMake(0.0f,0.0f) icon:[UIImage imageNamed:@"1.jpg"]]; [_mapView addOverlay:ground]; //新增圖片圖層覆蓋物(第二種:根據指定區域生成) CLLocationCoordinate2D coordground[2] = {0}; coordground[0].latitude = 22.2538; coordground[0].longitude = 114.0672; coordground[1].latitude = 22.2038; coordground[1].longitude = 114.1072; BMKCoordinateBounds bound; bound.southWest = coordground[0]; bound.northEast = coordground[1]; BMKGroundOverlay* ground2 = [BMKGroundOverlay groundOverlayWithBounds: bound icon:[UIImage imageNamed:@"1.jpg"]]; [_mapView addOverlay:ground2]; [self.view addSubview:_mapView]; } //根據overlay生成對應的View - (BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id <BMKOverlay>)overlay{ if ([overlay isKindOfClass:[BMKPolyline class]]){ BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay] ; polylineView.strokeColor = [[UIColor redColor] colorWithAlphaComponent:1]; polylineView.lineWidth = 5.0; return polylineView; } else if ([overlay isKindOfClass:[BMKArcline class]]) { BMKArclineView* arclineView = [[BMKArclineView alloc] initWithOverlay:overlay] ; arclineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.5]; arclineView.lineWidth = 5.0; return arclineView; } else if ([overlay isKindOfClass:[BMKPolygon class]]){ BMKPolygonView* polygonView = [[BMKPolygonView alloc] initWithOverlay:overlay]; polygonView.strokeColor = [[UIColor purpleColor] colorWithAlphaComponent:1]; polygonView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.2]; polygonView.lineWidth = 5.0; return polygonView; } else if ([overlay isKindOfClass:[BMKCircle class]]){ BMKCircleView* circleView = [[BMKCircleView alloc] initWithOverlay:overlay]; circleView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5]; circleView.strokeColor = [[UIColor yellowColor] colorWithAlphaComponent:0.5]; circleView.lineWidth = 10.0; return circleView; } else if ([overlay isKindOfClass:[BMKGroundOverlay class]]){ BMKGroundOverlayView* groundView = [[BMKGroundOverlayView alloc] initWithOverlay:overlay] ; groundView.backgroundColor=[UIColor yellowColor]; return groundView; } return nil; } -(void)viewDidAppear:(BOOL)animated { BMKPointAnnotation *pointAnnotation=[[BMKPointAnnotation alloc]init]; CLLocationCoordinate2D coor; coor.latitude=22.5538; coor.longitude=114.0672; pointAnnotation.coordinate=coor; pointAnnotation.title=@"這裡是少年宮"; [_mapView addAnnotation:pointAnnotation]; //移除大頭針 // if (annotation != nil) { // [_mapView removeAnnotation:annotation]; // } } //新增大頭針 - (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation { if ([annotation isKindOfClass:[BMKPointAnnotation class]]) { BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"]; newAnnotationView.pinColor = BMKPinAnnotationColorPurple; newAnnotationView.animatesDrop = YES;// 設定該標註點動畫顯示 return newAnnotationView; } return nil; } -(void)viewWillAppear:(BOOL)animated { [_mapView viewWillAppear]; _mapView.delegate=self; } -(void)viewWillDisappear:(BOOL)animated { [_mapView viewWillDisappear]; _mapView.delegate=nil; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end