篆体字作品 | 篆体字知识 | 加入收藏 篆体字转换器软件可转换多种篆体字在线预览 网页版 V2.0
篆体字转换器

当前位置:篆体字网 > 知识库 >

百度地图api开发

时间:2024-01-05 01:38:25 编辑:篆字君 来源:篆体字网

CLLocationCoordinate2D coor;
coor.latitude=self._latitude;
coor.longitude=self._longitude;
NSDictionary*tip= BMKBaiduCoorForWgs84(coor);
CLLocationCoordinate2D coor1= BMKCoorDictionaryDecode(tip);
BMKCoordinateRegion viewRegion=BMKCoordinateRegionMake(coor1,BMKCoordinateSpanMake(0.05,0.05));
BMKCoordinateRegion adjustedRegion=[_mapViewregionThatFits:viewRegion];
[_mapViewsetRegion:adjustedRegion animated:YES];
}
清除地图上所有痕迹和路线
-(void)clereOldYJDH{
NSArray*array=[NSArray arrayWithArray:_mapView.annotations];
[_mapViewremoveAnnotations:array];
array=[NSArray arrayWithArray:_mapView.overlays];
[_mapViewremoveOverlays:array];
[selfRegion];
}
//当选中一个annotationviews时,调用此接口
- (void)mapView:(BMKMapView *)mapViewdidSelectAnnotationView:(BMKAnnotationView *)view
{
NSLog(@"选中一个annotationviews:%f,%f",view.annotation.coordinate.latitude,view.annotation.coordinate.longitude);
}
//当取消选中一个annotationviews时,调用此接口
- (void)mapView:(BMKMapView *)mapViewdidDeselectAnnotationVie w:(BMKAnnotationView *)view{
NSLog(@"取消选中一个annotation views");
}
//当mapView新添加annotationviews时,调用此接口
- (void)mapView:(BMKMapView *)mapViewdidAddAnnotationViews:(NSArray *)views
{
NSLog(@"mapView新添加annotation views");
}
//当点击annotationview弹出的泡泡时,调用此接口
- (void)mapView:(BMKMapView *)mapViewannotationViewForBubble:(BMKAnnotationView *)view
{
NSLog(@"点击annotation view弹出的泡泡");
}
//拖动annotationview时view的状态变化
- (void)mapView:(BMKMapView *)mapViewannotationView:(BMKAnnotationView *)viewdidChangeDragState:(BMKAnnotationViewDragSta te)newStatefromOldState:(BMKAnnotationViewDragSta te)oldState
{
NSLog(@"动annotation view时view的状态变化");
}
//标注呈绿色样式大头钉
((BMKPinAnnotationView *)annotationView).pinColor=BMKPinAnnotationColorGre en;
//允许用户拖动
[annotationView setDraggable:YES];
//气泡框左侧显示的View,可自定义
annotationView.leftCalloutAccessoryView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_location.png"]];
//气泡框右侧显示的View 可自定义
annotationView.rightCalloutAccessoryVie w=selectButton;
//让标注在进入界面时就处于弹出气泡框的状态
[annotationView setSelected:YES animated:YES];
//整个标注的偏移量
annotationView.centerOffset=CGPointMake(0,-(annotationView.frame.size.height * 0.5));
annotationView.annotation=annotation;//绑定对应的标点经纬度
annotationView.canShowCallout=TRUE;//允许点击弹出气泡框
在地图上定制标注替代大头钉,可以将文字图片所有能加到view中的,都可以以大头钉的形式显示出来,需要将view转换为image主要代码,最重要的是知道这个原理,然后实现起来就很简单:
- (BMKAnnotationView *)mapView:(BMKMapView *)viewviewForAnnotation:(id)annotation
在这个委托中实现如下代码
UIView *viewForImage=[[UIView alloc]initWithFrame:CGRectMake(0, 0,132, 64)];
UIImageView *imageview=[[UIImageViewalloc]initWithFrame:CGRectMake(0, 0, 32, 64)];
[imageview setImage:[UIImage imageNamed:@"车位置.png"]];
[viewForImage addSubview:imageview];
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(32, 0, 100,64)];
label.text=@"陈双超";
label.backgroundColor=[UIColor clearColor];
[viewForImage addSubview:label];
annotationView.image=[self getImageFromView:viewForImage];
-(UIImage *)getImageFromView:(UIView *)view{
UIGraphicsBeginImageCont ext(view.bounds.size);
[view.layerrenderInContext:UIGraphicsGetCurrentCont ext()];
UIImage*image=UIGraphicsGetImageFromCu rrentImageContext();
UIGraphicsEndImageContex t();
returnimage;
}
在网上发现别人专门建立view来定制气泡和专门建立文件来定制大头钉,觉得那方法对代码管理起来更简单,可读性强。值得学习http://www.kuaipan.cn/file/id_30491149655345085.htm
@interface KYBubbleView : UIScrollView{ //UIView是气泡view的本质
NSDictionary*_infoDict;
UILabel *titleLabel;//标题label
UILabel *detailLabel;//副标题label
UILabel *contactLabel; //联系人
UILabel *homeAddresslabel; //家庭地址
UIButton *rightButton;
NSUInteger index;
}
#import "BMKPointAnnotation.h"
@interface KYPointAnnotation : BMKPointAnnotation {
NSUInteger_tag;
}
@property NSUInteger tag;
@end
部分效果图

Copyright:2021-2023 篆体字转换器 www.dddtedu.com All rights reserved.