百度地图之基础地图

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

时间: 2024-08-29 05:51:23

百度地图之基础地图的相关文章

Android--百度地图之基础地图(三)

开发者可利用SDK提供的接口,使用百度为您提供的基础地图数据.目前百度地图SDK所提供的地图等级为3-21级,所包含的信息有建筑物.道路.河流.学校.公园等内容. V3.7.0起,地图支持缩放至21级,暂不支持卫星图.热力图.交通路况图层的21级显示,打开以上类型图层,地图会自动缩放到20级. 所有叠加或覆盖到地图的内容,我们统称为地图覆盖物.如标注.矢量图形元素(包括:折线.多边形和圆等).定位图标等.覆盖物拥有自己的地理坐标,当您拖动或缩放地图时,它们会相应的移动. 百度地图SDK为广大开发

基础地图Android SDK

开发者可利用SDK提供的接口,使用百度为您提供的基础地图数据.目前百度地图SDK所提供的地图等级为3-21级,所包含的信息有建筑物.道路.河流.学校.公园等内容. V3.7.0起,地图支持缩放至21级,暂不支持卫星图.热力图.交通路况图层的21级显示,打开以上类型图层,地图会自动缩放到20级. 所有叠加或覆盖到地图的内容,我们统称为地图覆盖物.如标注.矢量图形元素(包括:折线.多边形和圆等).定位图标等.覆盖物拥有自己的地理坐标,当您拖动或缩放地图时,它们会相应的移动. 百度地图SDK为广大开发

IOS百度地图使用基础指南+原生分享&友盟分享

1.地图 1.获取用户的经纬度(CLLocationManager) 创建属性:CLLocationManager *mgr; 遵守协议:<CLLocationManagerDelegate> a>创建定位管理器 self.mgr = [[CLLocationManager alloc] init]; b>设置代理 self.mgr.delegate = self; c>开始定位 [self.mgr startUpdatingLocation]; 代理方法: -(void)l

百度地图、高德地图的数据从哪里得到的?[声明我只是此文章的搬运工,从百度知道复制来的]

要说数据来源,首先得对地图数据做一个分类,因为不同分类的数据,其来源,采集方法都是有大不同的. 要明白地图的数据分类,必须先理解一个概念,就是地图图层的概念: 如上图,电子地图对我们实际空间的表达,事实上是通过不同的图层去描述,然后通过图层叠加显示来进行表达的过程. 对于我们地图应用目标的不同,叠加的图层也是不同的,用以展示我们针对目标所需要信息内容. 其次呢,我引入一下矢量模型和栅格模型的概念,GIS(电子地图)采用两种不同的数学模型来对现实世界进行模拟: 矢量模型:同多X,Y(或者X,Y,Z

百度地图、高德地图的数据从哪里得到的?

要说数据来源,首先得对地图数据做一个分类,因为不同分类的数据,其来源,采集方法都是有大不同的. 要明白地图的数据分类,必须先理解一个概念,就是地图图层的概念:        如上图,电子地图对我们实际空间的表达,事实上是通过不同的图层去描述,然后通过图层叠加显示来进行表达的过程. 对于我们地图应用目标的不同,叠加的图层也是不同的,用以展示我们针对目标所需要信息内容. 其次呢,我引入一下矢量模型和栅格模型的概念,GIS(电子地图)采用两种不同的数学模型来对现实世界进行模拟: 矢量模型:同多X,Y(

关于百度地图API的地图坐标转换问题

原文:关于百度地图API的地图坐标转换问题 我在之前的文章利用html5获取经纬度并且在百度地图中显示位置中使用了百度地图的API来显示html5获取的地理位置,在文中我说过这样的话,我说百度地图的准确度不怎么精确,偏差很大.这里我要更正下: 国际经纬度坐标标准为WGS-84,国内必须至少使用国测局制定的GCJ-02,对地理位置进行首次加密.百度坐标在此基础上,进行了BD-09二次加密措施,更加保护了个人隐私.百度对外接口的坐标系并不是GPS采集的真实经纬度,需要通过坐标转换接口进行转换. 由此

百度地图和谷歌地图使用的地理位置坐标标准以及转换

最近在使用百度地图和谷歌地图搜集和处理数据,发现百度和谷歌地图使用的地理位置坐标标准有很大的不同.首先,百度地图的卫星地图和街道地图使用的都是BD-09标准,该标准是在中国国测局地理坐标标准GCJ-02的基础上加密生成.谷歌卫星地图在中国和世界上使用的都是WGS-84标准,但是谷歌街道地图在中国使用的是GCJ-02标准,在世界上其他国家使用的依然是WGS-84标准.在中国之所以使用GCJ-02标准,是因为相关国家的规定要求中国境内的电子地图必须使用原始坐标加密后的GCJ-02标准,以保护国家的地

vue中实现百度地图拖拽地图定位功能

效果如果所示,拖动地图.中间图标不动,并且自动获取地图当前中心点的经纬度.然后就可以用经纬度做其他的操作了...首先查看了百度地图的api.能实现这个功能最贴近的就是marker.marker可以拖拽,但是地图却动不了,我还用了另外一种是自己自定义一个marker.并且让marker相对地图位置绝对定位,地图拖拽,marker不动,拖拽结束后使用marker.getposition来获取当前位置,但是有个问题.自定义的marker在地图拖动的时候就看不见了..应该是层级问题.让地图给挡住了..太

百度做各种各样的地图API教会你

注意api的密钥  ak在我的云盘里,您可以自己申请! 百度做各种各样的地图API教会你,布布扣,bubuko.com