在iOS开发中,地图算是一个比较重要的模块。我们常用的地图有高德地图,百度地图,谷歌地图,对于中国而言,苹果公司已经不再使用谷歌地图,官方使用的是高德地图。下面将讲述一下百度地图开发过程中的一些小的知识点。

对于如何配置百度地图的开发环境,在此不再讲述,具体可以参考:http://developer.baidu.com/map/index.php?title=iossdk/guide/buildproject

百度地图iOS的API下载地址:http://developer.baidu.com/map/index.php?title=iossdk/sdkiosdev-download

关于百度地图的基本使用,我们可以参考百度地图的开发文档,在此主要总结一下开发文档中一些重要的知识点和延伸点。(地图版本IOS SDK 2.9.0)

首先说明一下百度地图开发中可能遇到的问题:

如何添加标注(系统标注和自定义标注)

iOS-BMK标注&覆盖物

 

 1 //添加标记
 2 -(void)viewDidAppear:(BOOL)animated
 3 {
 4     /*
 5     for (int i = 0; i < 3; i++) {
 6         BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
 7         CLLocationCoordinate2D coor;
 8         coor.latitude = 39.915 + i*2;
 9         coor.longitude = 116.404 + i*2;
10         annotation.coordinate = coor;
11         annotation.title = @"这里是北京";
12         [myMapView addAnnotation:annotation];
13     }
14     */
15     BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
16     CLLocationCoordinate2D coor;
17     coor.latitude = 39.915;
18     coor.longitude = 116.404;
19     annotation.coordinate = coor;
20     annotation.title = @"这里是北京";
21     annotation.subtitle = @"1";
22     //[myMapView addAnnotation:annotation];
23     
24     BMKPointAnnotation* annotation1 = [[BMKPointAnnotation alloc]init];
25     CLLocationCoordinate2D coor1;
26     coor1.latitude = 38.915;
27     coor1.longitude = 113.404 + 2;
28     annotation1.coordinate = coor1;
29     annotation1.title = @"这里也是北京";
30     annotation1.subtitle = @"2";
31     //[myMapView addAnnotation:annotation1];
32     
33     BMKPointAnnotation* annotation2 = [[BMKPointAnnotation alloc]init];
34     CLLocationCoordinate2D coor2;
35     coor2.latitude = 38.915;
36     coor2.longitude = 119.404 + 2;
37     annotation2.coordinate = coor2;
38     annotation2.title = @"这里同样是北京";
39     annotation2.subtitle = @"3";
40     //[myMapView addAnnotation:annotation2];
41     
42     NSArray *arr = [NSArray arrayWithObjects:annotation,annotation1,annotation2, nil];
43     [myMapView addAnnotations:arr];
44 }
45 
46 -(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
47 {
48     if ([annotation isKindOfClass:[BMKPointAnnotation class]])
49     {
50         BMKPinAnnotationView *newAnnotationView = (BMKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"AnnotationView"];
51         newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"AnnotationView"];
52         newAnnotationView.pinColor = BMKPinAnnotationColorPurple;
53         newAnnotationView.animatesDrop = YES;// 设置该标注点动画显示
54         return newAnnotationView;
55     }
56     return nil;
57 }
系统标记

相关文章:

  • 2021-09-17
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-02-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
相关资源
相似解决方案