亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > iOS > 正文

iOS實現百度地圖拖拽后更新位置以及反編碼

2019-10-21 18:42:53
字體:
來源:轉載
供稿:網友

前言

最近在開發中遇到了百度地圖的開發,功能類似于微信中的發送位置,拖拽從新定位,以及反編碼,列表附近的位置。分析出來供大家參考學習,下面話不多說了,來一起看看詳細的介紹吧。

效果圖:

ios,百度地圖反編碼,地理位置反編碼,ios百度地圖拖拽事件

百度地圖拖拽更新位置.gif

實現思路

思路就是將一個UIImageView固定在地圖中間,每次更新位置,給UIImageView添加動畫即可。

代碼如下:

#import "FTBasicController.h"typedef void (^SelectBlock) (NSString *address,CLLocationCoordinate2D select);@interface FTUploadAddressController : FTBasicController@property(nonatomic, copy)SelectBlock selectBlock;@end#import "FTUploadAddressController.h"#import "FTBMKPoiInfo.h"#import "FTPoiCell.h"@interface FTUploadAddressController ()@property(nonatomic,strong)BMKLocationService *locService;@property(nonatomic,strong)BMKUserLocation *userLocation;@property(nonatomic,strong)BMKMapView *mapView;@property(nonatomic,strong)UITableView *tableview;@property(nonatomic,strong)BMKGeoCodeSearch *geocodesearch;@property(nonatomic,strong)UIImageView *loactionView;@property(nonatomic,strong)NSMutableArray *dataA;@property(nonatomic,strong)LxButton *poiBackBtn;@property(nonatomic,assign)CLLocationCoordinate2D selectedCoordinate;@property(nonatomic,strong)NSString *selectAddress;@end@implementation FTUploadAddressController-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.fd_interactivePopDisabled = YES; if (!([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways || [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse) &&[CLLocationManager authorizationStatus] != kCLAuthorizationStatusNotDetermined){  [self judgeOpenlocation]; }else{  [_mapView viewWillAppear];  _mapView.delegate = self; // 此處記得不用的時候需要置nil,否則影響內存的釋放  _locService.delegate = self;   _geocodesearch.delegate = self; // 此處記得不用的時候需要置nil,否則影響內存的釋放  _mapView.showsUserLocation = NO;//先關閉顯示的定位圖層  _mapView.userTrackingMode = 0;  _mapView.showsUserLocation = YES;//顯示定位圖層  [self.locService startUserLocationService]; }}-(void)judgeOpenlocation{ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"打開[定位服務]來允許[應用名字]確定您的位置" message:@"請在系統設置中開啟定位服務(設置>隱私>定位服務>應用名字>始終)" preferredStyle:UIAlertControllerStyleAlert]; [alertVC addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]]; [alertVC addAction:[UIAlertAction actionWithTitle:@"去設置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {  if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.000000) {   //跳轉到定位權限頁面   NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];   if( [[UIApplication sharedApplication]canOpenURL:url] ) {    [[UIApplication sharedApplication] openURL:url];   }  }else {   //跳轉到定位開關界面   NSURL *url = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];   if( [[UIApplication sharedApplication]canOpenURL:url] ) {    [[UIApplication sharedApplication] openURL:url];   }  } }]]; [self presentViewController:alertVC animated:YES completion:nil];}-(void)viewWillDisappear:(BOOL)animated{  self.fd_interactivePopDisabled = NO; [_mapView viewWillDisappear]; _mapView.delegate = nil; // 不用時,置nil [self.locService stopUserLocationService];  _geocodesearch.delegate = nil; // 不用時,置nil _locService.delegate = nil;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title = @"所在位置";  self.locService = [[BMKLocationService alloc]init]; self.geocodesearch = [[BMKGeoCodeSearch alloc]init];  [self setup];  self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"return"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backReturn)];}-(void)backReturn{ if (self.selectBlock) {  self.selectBlock(self.selectAddress, self.selectedCoordinate);  [self.navigationController popViewControllerAnimated:YES]; }}-(void)setup{  [self.view addSubview:self.mapView]; [self.view addSubview:self.tableview]; [self.mapView addSubview:self.loactionView]; [self.mapView addSubview:self.poiBackBtn];  [self.poiBackBtn LX_SetShadowPathWith:[UIColor grayColor] shadowOpacity:0.5 shadowRadius:5 shadowSide:LXShadowPathBottom shadowPathWidth:3]; FTWS(weakSelf); [self.poiBackBtn addClickBlock:^(UIButton *button) {   [weakSelf.mapView setCenterCoordinate:weakSelf.userLocation.location.coordinate]; }];}- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation{ //  NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude); [_mapView updateLocationData:userLocation]; self.userLocation = userLocation; [self.mapView setCenterCoordinate:userLocation.location.coordinate]; BMKReverseGeoCodeOption * option = [[BMKReverseGeoCodeOption alloc]init]; option.reverseGeoPoint = userLocation.location.coordinate; BOOL flag = [_geocodesearch reverseGeoCode:option]; if (flag) {  } //更新位置之后必須停止定位, [_locService stopUserLocationService];}-(void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ NSLog(@"地圖拖動"); [UIView animateWithDuration:0.30 animations:^{  self.loactionView.centerY -=8; } completion:^(BOOL finished) {  self.loactionView.centerY +=8; }]; CGPoint touchPoint = self.mapView.center; CLLocationCoordinate2D touchMapCoordinate = [self.mapView convertPoint:touchPoint toCoordinateFromView:self.mapView];//這里touchMapCoordinate就是該點的經緯度了 NSLog(@"touching %f,%f",touchMapCoordinate.latitude,touchMapCoordinate.longitude); //選擇的上傳地址 self.selectedCoordinate = touchMapCoordinate; BMKReverseGeoCodeOption * option = [[BMKReverseGeoCodeOption alloc]init]; option.reverseGeoPoint = touchMapCoordinate; BOOL flag = [_geocodesearch reverseGeoCode:option]; if (flag) {  }}#pragma mark---獲取反編碼的數據----(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{  BMKAddressComponent *component=[[BMKAddressComponent alloc]init];  component=result.addressDetail; [self.dataA removeAllObjects]; for (int i =0; i< result.poiList.count; i++) {  BMKPoiInfo *info = result.poiList[i];  FTBMKPoiInfo *ftInfo =[[FTBMKPoiInfo alloc]init];  ftInfo.address = info.address;  ftInfo.seleced = NO;  if (i == 0) {   ftInfo.seleced = YES;   self.selectAddress = ftInfo.address;  }  [self.dataA addObject:ftInfo]; } [self.tableview reloadData];}#pragma mark--- 定位的方法--- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation{ [_mapView updateLocationData:userLocation]; // NSLog(@"heading is %@",userLocation.heading);}-(BMKMapView *)mapView{ if (!_mapView) {  _mapView =[[BMKMapView alloc]initWithFrame:CGRectMake(0, NAVH, Device_Width, 350)];  _mapView.zoomLevel = 18;  _mapView.minZoomLevel = 3;  _mapView.maxZoomLevel = 21;//  BMKLocationViewDisplayParam *displayParam = [[BMKLocationViewDisplayParam alloc]init];//  displayParam.isRotateAngleValid = true;//跟隨態旋轉角度是否生效//  displayParam.isAccuracyCircleShow = false;//精度圈是否顯示//  displayParam.locationViewOffsetX = 0;//定位偏移量(經度)//  displayParam.locationViewOffsetY = 0;//定位偏移量(緯度)//  [_mapView updateLocationViewWithParam:displayParam];  } return _mapView;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataA.count;}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ FTPoiCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; if (!cell) {  cell =[[FTPoiCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; } FTBMKPoiInfo *info = self.dataA[indexPath.row]; cell.info = info; return cell;}-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; FTBMKPoiInfo *info = self.dataA[indexPath.row]; self.selectAddress = info.address; [self.dataA enumerateObjectsUsingBlock:^(FTBMKPoiInfo * obj, NSUInteger idx, BOOL * _Nonnull stop) {  if (obj == info) {   obj.seleced = YES;  }else{   obj.seleced = NO;  }  [self.tableview reloadData]; }]; if (self.selectBlock) {  self.selectBlock(self.selectAddress,self.selectedCoordinate);    [self.navigationController popViewControllerAnimated:YES]; } }-(UITableView *)tableview{  if (!_tableview) {  _tableview =[[UITableView alloc]initWithFrame:CGRectMake(0, self.mapView.bottom, Device_Width, Device_Height - self.mapView.bottom) style:UITableViewStylePlain];  _tableview.delegate = self;  _tableview.dataSource = self;  _tableview.showsVerticalScrollIndicator = NO;  _tableview.showsHorizontalScrollIndicator = NO;  _tableview.tableFooterView = [UIView new];  _tableview.rowHeight = 44;  [_tableview registerNib:[UINib nibWithNibName:@"FTPoiCell" bundle:nil] forCellReuseIdentifier:@"cell"];//  [_tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];    } return _tableview;}-(NSMutableArray *)dataA{ if (!_dataA) {  _dataA =[NSMutableArray array]; } return _dataA;}-(UIImageView *)loactionView{ if (!_loactionView) {  _loactionView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ditu_red"]];  _loactionView.center = CGPointMake(self.mapView.width/2, self.mapView.height/2);   } return _loactionView;}-(LxButton *)poiBackBtn{ if (!_poiBackBtn) {  _poiBackBtn =[LxButton LXButtonWithTitle:nil titleFont:nil Image:nil backgroundImage:nil backgroundColor:[UIColor whiteColor] titleColor:nil frame:CGRectMake(Device_Width - 75, self.mapView.height - 75, 50, 50)];  [_poiBackBtn setFTCornerdious:25];  UIImageView *imageView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"poi_back"]];     imageView.center = CGPointMake(25, 25);  [_poiBackBtn addSubview:imageView];     } return _poiBackBtn;}@end

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網的支持。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
97**国产露脸精品国产| 国产精品热视频| 98视频在线噜噜噜国产| 亚洲影视九九影院在线观看| 亚洲国产欧美久久| 亚洲视频视频在线| 亚洲第一黄色网| 午夜精品福利电影| 青青精品视频播放| 国产精品在线看| 欧美寡妇偷汉性猛交| 国产精品三级在线| 中文国产成人精品久久一| 欧美日韩日本国产| 在线观看国产精品日韩av| 一区二区在线免费视频| 亚洲人免费视频| xxx一区二区| 欧美激情小视频| 亚洲欧美日韩国产中文| 亚洲3p在线观看| 成人精品久久一区二区三区| 日本国产一区二区三区| 日韩欧美在线观看| 国产精品老牛影院在线观看| www高清在线视频日韩欧美| 欧美片一区二区三区| 欧美日韩在线视频一区| 色爱av美腿丝袜综合粉嫩av| 91精品啪aⅴ在线观看国产| 91av在线免费观看| 国产成人久久精品| 亚洲第一福利网| 国产精品精品视频一区二区三区| 色综合久久88| 亚洲999一在线观看www| 亚洲精品小视频在线观看| 久久精品国产欧美激情| 国内精品视频在线| 粉嫩av一区二区三区免费野| 北条麻妃久久精品| 中文字幕日本精品| 国产精品小说在线| 国产午夜精品一区理论片飘花| 国产欧美va欧美va香蕉在| 亚洲精品国产拍免费91在线| 成人免费视频97| 久久久噜噜噜久久| 国产视频久久久久| 国产精品久久久久久久天堂| 成人国产精品久久久久久亚洲| 欧美日韩免费观看中文| 欧美有码在线视频| 久久久欧美一区二区| 精品五月天久久| 国产精品一区二区三区在线播放| 国产精品入口尤物| 亚洲精品国产精品国自产观看浪潮| 一本色道久久综合狠狠躁篇怎么玩| 欧美久久精品一级黑人c片| 久久亚洲综合国产精品99麻豆精品福利| 欧美日韩中文在线观看| 久久久91精品国产一区不卡| 亚洲伦理中文字幕| 国产日韩精品视频| 色在人av网站天堂精品| 自拍偷拍亚洲精品| 亚洲天堂久久av| 韩曰欧美视频免费观看| 久久91精品国产91久久久| 午夜精品久久久久久99热| 日本中文字幕不卡免费| 久久国产精品电影| 两个人的视频www国产精品| 亚洲精品不卡在线| 亚洲欧美日韩国产成人| 国语自产精品视频在免费| 欧美在线www| 日日摸夜夜添一区| 精品人伦一区二区三区蜜桃免费| 精品欧美aⅴ在线网站| 精品国产精品自拍| 欧美俄罗斯性视频| 这里只有精品久久| 欧美丰满片xxx777| 亚洲欧美国产一区二区三区| 亚洲精品wwwww| 日韩av网址在线观看| 久久青草精品视频免费观看| 欧美亚洲成人网| 欧美黑人极品猛少妇色xxxxx| 亚洲成年人影院在线| 国产精品成人一区| 自拍偷拍亚洲在线| 国语自产精品视频在线看抢先版图片| 欧美日韩在线视频一区二区| 日韩黄在线观看| 欧美成人在线影院| 成人欧美一区二区三区在线湿哒哒| 日韩中文字幕在线免费观看| 日韩成人久久久| 91亚洲国产成人精品性色| 欧美日韩亚洲一区二区三区| 亚洲成人教育av| 日韩av在线免播放器| 日本高清视频精品| 欧美日韩成人在线观看| 国产999精品| 久久亚洲精品一区| 91禁国产网站| 亚洲欧美国产高清va在线播| 国产福利视频一区二区| 欧美一级在线亚洲天堂| 欧美午夜精品在线| 日韩在线观看免费高清完整版| 欧美一区二区色| 一本色道久久88亚洲综合88| 亚洲欧美国产一本综合首页| 高清欧美性猛交xxxx黑人猛交| 日韩中文有码在线视频| 亚洲精品美女在线| 欧美男插女视频| 亚洲成人久久电影| 欧美交受高潮1| 亚洲黄色免费三级| 国自产精品手机在线观看视频| 日产日韩在线亚洲欧美| 久久久噜久噜久久综合| 国产美女主播一区| 日韩激情av在线播放| 日韩欧美极品在线观看| 91成人免费观看网站| 欧美激情视频在线免费观看 欧美视频免费一| 日韩欧美中文在线| 国产精品久久久久久久久久99| 成人妇女免费播放久久久| 亚洲自拍偷拍福利| 亚洲va欧美va国产综合久久| 国产美女高潮久久白浆| 亚洲肉体裸体xxxx137| 精品视频—区二区三区免费| 日韩美女中文字幕| 欧洲一区二区视频| 欧美视频免费在线观看| 欧美三级免费观看| 国产一区二区日韩| 国语自产偷拍精品视频偷| 欧美激情欧美激情在线五月| 91在线视频九色| 91老司机在线| 日本成人激情视频| 亚洲аv电影天堂网| 国产精品日韩av| 亚洲欧美日韩直播| 亚洲国产精品小视频| 欧美日韩精品国产| 久久久久久国产精品久久| 日韩精品极品视频| 91精品久久久久久久久久久久久| 亚洲电影免费观看高清| 精品久久久香蕉免费精品视频| 欧洲永久精品大片ww免费漫画| 久久久噜噜噜久久中文字免| 国产精品免费视频xxxx|