一起玩地图

2015-12-17  本文已影响56人  王老板

地图的分类: 百度地图 腾讯地图 高德地图 苹果本身

http://developer.baidu.com/map/ (详情请查看网站)

  <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>baidumap</string>
    </array>
(void)viewWillAppear:(BOOL)animated      
{      
    [_mapView viewWillAppear];      
    _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放      
}      
-(void)viewWillDisappear:(BOOL)animated      
{      
        [_mapView viewWillDisappear];      
      _mapView.delegate = nil; // 不用时,置nil      
}
@interface BaiduMapApiDemoAppDelegate : NSObject <UIApplicationDelegate> {   
       UIWindow *window;    
       UINavigationController *navigationController;     
       BMKMapManager* _mapManager;    
}```
 * 在当前文件中添加对BMKMapManager的初始化,并填入您申请的授权Key,示例如下http://lbsyun.baidu.com/apiconsole/key ,在.h中写代理方法``BMKMapViewDelegate``定义一个变量``    BMKMapManager* _mapManager;
``

_mapManager = [[BMKMapManager alloc]init];
// 如果要关注网络及授权验证事件,请设定 generalDelegate参数
BOOL ret = [_mapManager start:@"sH4enIjfG585foGEtlIghsog" generalDelegate:nil];
if (!ret) {
NSLog(@"manager start failed!");
}```

 _mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    _mapView.centerCoordinate =CLLocationCoordinate2DMake(38.8496481, 121.517977);
    _mapView.zoomLevel = 15;
上一篇 下一篇

猜你喜欢

热点阅读