java 百度地图demo_百度地图 - demo

//

//  HYBBaiduMapHelper.m

//  BaiduMapDemo

//

//  Created by 黄仪标 on 14/11/18.

//  Copyright (c) 2014年 黄仪标. All rights reserved.

//

#import "HYBBaiduMapHelper.h"

@interface HYBBaiduMapHelper () 

BMKGeneralDelegate,

BMKMapViewDelegate,

BMKRouteSearchDelegate> {

BMKMapManager             *_mapManager;

HYBUserLocationCompletion _locationCompletion;

HYBRouteSearchCompletion  _routeSearchCompletion;

BMKMapView                *_mapView;

BMKLocationService        *_locationService;

BMKRouteSearch            *_routeSearch;

}

@end

@implementation HYBBaiduMapHelper

+ (HYBBaiduMapHelper *)shared {

static HYBBaiduMapHelper *baiduMapHelper =nil;

static dispatch_once_t onceToken = 0;

dispatch_once(&onceToken, ^{

if (!baiduMapHelper) {

baiduMapHelper = [[[selfclass]alloc]init];

}

});

return baiduMapHelper;

}

- (instancetype)init {

if (self = [superinit]) {

_mapManager = [[BMKMapManageralloc]init];

}

return self;

}

- (BOOL)startWithAppKey:(NSString *)appKey {

if (![appKeyisKindOfClass:[NSStringclass]] || appKey.length == 0 || appKey ==nil) {

return NO;

}

return [_mapManagerstart:appKeygeneralDelegate:self];

}

- (void)locateInView:(UIView *)mapSuerViewframe:(CGRect)framewithCompletion:(HYBUserLocationCompletion)completion {

_locationCompletion = [completioncopy];

[_locationServicestopUserLocationService];

_locationService =nil;

_locationService.delegate =nil;

_locationService = [[BMKLocationServicealloc]init];

[_locationServicestartUserLocationService];

if (_mapView) {

[_mapViewremoveFromSuperview];

_mapView =nil;

}

_mapView.delegate =nil;

_mapView.showsUserLocation = NO;

_mapView = [[BMKMapViewalloc]initWithFrame:frame];

[mapSuerViewaddSubview:_mapView];

_mapView.delegate = self;

// 先关闭显示的定位图层

_mapView.showsUserLocation = NO;

// 设置定位的状态

_mapView.userTrackingMode = BMKUserTrackingModeNone;

_mapView.showsUserLocation = YES;

return;

}

- (void)viewWillAppear {

[_mapViewviewWillAppear];

_mapView.delegate = self;

_locationService.delegate = self;

_routeSearch.delegate = self;

return;

}

- (void)viewWillDisappear {

[_mapViewviewWillDisappear];

_mapView.delegate =nil;

_locationService.delegate =nil;

_routeSearch.delegate =nil;

return;

}

- (void)viewDidDeallocOrReceiveMemoryWarning {

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值