在做项目集成百度地图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