高德地图大头针功能_高德地图 (多个大头针显示)
高德地图
运用场景:先获取本机经纬度 ,从服务端获取周围的小区和停车场的经纬度,通过服务端返回的type赋值给大头针的title来判断是小区还是停车场
1,首先实例化地图
#import
#import
#import
#import
@property (nonatomic, strong) MAMapView *mapView;
#pragma mark - 懒加载
-(MAMapView *)mapView{
if (!_mapView){
_mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64-44)];
_mapView.backgroundColor = [UIColor whiteColor];
_mapView.delegate = self;
_mapView.zoomEnabled = YES;
_mapView.mapType = MAMapTypeStandard;
[_mapView setUserTrackingMode:MAUserTrackingModeFollow animated:YES];
_mapView.showsCompass= NO;
_mapView.compassOrigin= CGPointMake(_mapView.compassOrigin.x, 22);
_mapView.showsScale= NO;
_mapView.scaleOrigin= CGPointMake(_mapView.scaleOrigin.x, 22);
[_mapView setZoomLevel:16 animated:YES];
_mapView.showsUserLocation = YES;
[[LWLocationManager sharedManager]reverseGeocodeLocationSuccess:^(NSString *locationString) {
NSLog(@"locationString == %@",locationString);
} error:^(NSError *error) {
}];
}
return _mapView;
}
-(void)DatasinMap{//处理附近小区/停车场数据坐标
NSMutableArray *xiaoquArr = [NSMutableArray array];
/** 后台数据 **/
for(MLFoundCarModel *model in self.dataArray){
MAPointAnnotation *pointAnimate = [[MAPointAnnotation alloc]init];//创建大头针 循环创建
pointAnimate.coordinate = CLLocationCoordinate2DMake([model.latitude floatValue],[model.longitude floatValue]);
pointAnimate.title = model.ID;//把ID传给pointAnimate的title 进行判断是哪个大头针 这个比较重要
[xiaoquArr addObject:pointAnimate];//把大头针装到一个数组
}
[self.mapView addAnnotations:xiaoquArr];//再将数组给到mapview
}
/** 自定义大头针 **/
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id)annotation{
if(([annotation isKindOfClass:[MAUserLocation class]])){//本机经纬度
static NSString *userReuseIndetifier = @"userPointReuseIndetifier";
MAPinAnnotationView *annotationView = (MAPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:userReuseIndetifier];
if (annotationView == nil){
annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:userReuseIndetifier];
}
annotationView.canShowCallout = NO;
annotationView.animatesDrop = YES;
UILabel *name = [[UILabel alloc]initWithFrame:CGRectMake(-20, -20, 100, 20)];
name.adjustsFontSizeToFitWidth = YES;
name.textColor = White_Color;
name.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.3f];
name.layer.masksToBounds = YES;
name.layer.cornerRadius = 8.0f;
name.textAlignment = NSTextAlignmentCenter;
name.font = [UIFont fontWithName:@"Arial" size:11];
if(_types != 1){//搜索页面进来 隐藏
annotationView.image = [UIImage imageNamed:@"parkingspaces_mine_pressit"];
[annotationView addSubview:name];
}
double latitude = [[MLUserModel sharedUserInfo].latitude doubleValue];
double longitude = [[MLUserModel sharedUserInfo].longitude doubleValue];
CLLocation *location = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
//根据经纬度解析成位置
CLGeocoder *geocoder = [[CLGeocoder alloc]init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemark,NSError *error){
CLPlacemark *mark = [placemark objectAtIndex:0];
if(_types != 1){
NSLog(@"%@%@%@%@%@",mark.subLocality,mark.thoroughfare,mark.name,mark.locality,mark.subLocality);
_bottomView.myLocationTX.text = [NSString stringWithFormat:@"%@%@",mark.subLocality,mark.thoroughfare];
name.text = [NSString stringWithFormat:@"%@%@",mark.subLocality,mark.thoroughfare];//赋值
}
}];
return annotationView;
}
if ([annotation isKindOfClass:[MAPointAnnotation class]]){//自定义后台返回的坐标大头针
static NSString *customReuseIndetifier = @"customReuseIndetifier";
//MLCustomAnnotationView自定义的 参考下一篇
MLCustomAnnotationView *annotationView = (MLCustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:customReuseIndetifier];
if (annotationView == nil){
annotationView = [[MLCustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:customReuseIndetifier];
annotationView.canShowCallout = NO;
annotationView.draggable = YES;
annotationView.delegate = self;
annotationView.calloutOffset = CGPointMake(0, -5);
if(_types == 1){//搜索页面传过去的经纬度 进行大头针自定义
if([annotation.title isEqualToString:@"search"]){
annotationView.portrait = [UIImage imageNamed:@"parkingspaces_mine_pressit"];
annotationView.titles.text = _address;
}
}
//处理小区和停车场图片数据
for(MLFoundCarModel *model in _dataArray){
if([model.ID isEqualToString:annotation.title]){//判断是哪个大头针
annotationView.titles.text = model.number;
if([model.type isEqualToString:@"1"]){//小区
annotationView.portrait = [UIImage imageNamed:@"parking_mapposition_district"];
}else{//停车场
annotationView.portrait = [UIImage imageNamed:@"parking_mapposition_parkinglot"];
}
}
}
}
return annotationView;
}
return nil;
}
#pragma mark 在自定义大头针view里面写了代理,点击大头针跳转详情页面
-(void)clickAnnotionView:(NSString *)ID subtitle:(NSString *)subtitle{
MLRentSeatDetailsViewController *rentvc = [[MLRentSeatDetailsViewController alloc]init];
rentvc.carId = ID;
[self.navigationController pushViewController:rentvc animated:YES];
}
#pragma mark 显示具体位置
- (void)zoomToMapPoints:(MKMapView *)mapView annotations:(NSArray*)annotations{
double minLat = 360.0f, maxLat = -360.0f;
double minLon = 360.0f, maxLon = -360.0f;
for (MKPointAnnotation *annotation in annotations) {
if ( annotation.coordinate.latitude < minLat ) minLat = annotation.coordinate.latitude;
if ( annotation.coordinate.latitude > maxLat ) maxLat = annotation.coordinate.latitude;
if ( annotation.coordinate.longitude < minLon ) minLon = annotation.coordinate.longitude;
if ( annotation.coordinate.longitude > maxLon ) maxLon = annotation.coordinate.longitude;
}
CLLocationCoordinate2D center = CLLocationCoordinate2DMake((minLat + maxLat) / 2.0, (minLon + maxLon) / 2.0);
MKCoordinateSpan span = MKCoordinateSpanMake(maxLat - minLat, maxLon - minLon);
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);
[mapView setRegion:region animated:YES];
}
#pragma mark - MAMapViewDelegate
- (void)mapView:(MAMapView *)mapView didUpdateUserLocation:(MAUserLocation *)userLocation updatingLocation:(BOOL)updatingLocation {
//创建一个经纬度点:
MAPointAnnotation *point = [[MAPointAnnotation alloc] init];
//设置点的经纬度
point.coordinate = userLocation.location.coordinate;
}
//地图放大
CGFloat oldZoom = self.mapView.zoomLevel;
[self.mapView setZoomLevel:(oldZoom + 1) animated:YES];
//放小
CGFloat oldZoom = self.mapView.zoomLevel;
[self.mapView setZoomLevel:(oldZoom - 1) animated:YES];
//定位到当前位置
if(self.mapView.userLocation.updating && self.mapView.userLocation.location) {
[self.mapView setCenterCoordinate:self.mapView.userLocation.location.coordinate animated:YES];
}
}
高德地图大头针功能_高德地图 (多个大头针显示)相关推荐
- 高德地图大头针功能_【iOS】高德地图MAMapKit的使用:地图显示、添加大头针、导航、定位功能介绍...
最近在做基于高德地图的定位.导航及添加大头针的功能,特此记录下来...方便刚接触的同学参考... 一.申请 Key:获取用户Key 2.在"KEY管理"页面点击上方的"获 ...
- 高德推出查岗功能_新型「查岗」工具?高德推出「家人地图」新功能
苹果为 iPhone.iPad.iPod touch 内置了「查找」app,通过这个应用用户不仅可以快速定位不同设备,还可以与家人和朋友共享位置.此外,iOS 原生地图应用也支持「共享到达时间」,方便 ...
- 高德地图轨迹回放_高德上线“家人地图”功能
鞭牛士 7月14日消息,高德今日上线了"家人地图"功能,可以让家人随时看到彼此的位置,特别是针对空巢老人家庭,子女忙于工作,父母独自在家,老人有没有出门,外出去到了哪里,有没有偏离 ...
- 高德推出查岗功能_打尽渣男渣女的查岗神器?高德家人地图实测
从「高考防堵」攻略到「积水提醒」功能,再到「实时对讲」导航,高德地图在7月份接连推出了好几个新功能. 其中备受关注的,莫过于上周"低调"上线「家人地图」功能.一上线微博又双叒炸开了 ...
- 高德地图 街道范围_高德地图推出货车导航,解决3000万货车司机出行痛点
[猎云网(微信:ilieyun)北京]12月6日报道 高德地图今日推出全新的货车导航功能,易行平台出行方式及范围再次升级.这也是高德地图继推出无障碍地图之后,再一次面向特殊需求群体推出的新功能.货车导 ...
- android高德地图获取海拔_高德地图如何查经纬度和海拔
展开全部 高德地图测海拔的具体方法如下: 1.第一步打636f70793231313335323631343130323136353331333366306564开高德地图的网页,找到并点击下方那行小 ...
- 地图事件触发_使用地图触发功能处理相干事件
地图事件触发 本文介绍如何通过使用映射触发器来处理一致性事件. 基本上,建议使用Oracle Coherence中的分布式数据管理来研究Oracle Coherence API的基本配置和实现. 映射 ...
- 百度地图 绘制运动轨迹_百度地图创新破局:声音个性表达、出行精准预估与全球无碍...
12月20日-22日,在"极客公园创新大会十周年GeekPark IFX"未来趋势论坛上,百度地图事业部总经理李莹发表了题为<AI时代,地图的破局与思考>主题演讲,分享 ...
- wms地图绘制工具_移情地图,了解用户需求的利器
如果你想打造一款成功的产品,对你的用户有一个良好的了解是至关重要的.虽然用户体验设计师有许多技能可以帮助他们发展这种理解,但有一种关键技能有很多优势,它称为移情地图. User-Experience ...
最新文章
- きゃらコレ! -ALICESOFT- 汉化补丁
- 《CCNA安全640-554认证考试指南》——6.4节复习所有考试要点
- 解决maven cannot change version of project facet dynamic web module to 3.0
- C++中对象的构造顺序和析构顺序
- 《组合数学》——卡特兰数
- IIS启用页面Gzip压缩实现说明
- [转载] --- Fastjson1.2.68版及以下全版本远程代码执行漏洞通告
- 如何在CentOS 7中配置静态IP地址
- 一线大厂在用的反爬虫方法,看我如何破了它!
- ServerSideIncludeModule不是可识别的本机模块
- 医学专业失业率最高 三类相关行业人才紧缺
- 适合程序员的健身方法(转)
- 5款好用的开源JS图片裁剪插件(3个jQuery插件,2个AngularJS插件)
- 组态王历史记录用access_Access数据库与表在 组态王中使用.ppt
- Java 实例变量 和 实例方法 以及调用
- r语言 面板数据回归_在R语言中进行面板数据分析
- Spring Boot 接入支付宝,实战来了!
- 无法启动此程序,因为计算机中丢失MSVCR71.dll.丢失的解决方法分享
- Linux第二章:6.Xftp安装教程、使用Xftp进行远程文件传输
- grpc-go源码剖析七十四之什么情况下服务器端通知客户端,双方关闭链接?(goAway帧处理逻辑)