如何优化高德地图自定义大头针上的大头针

匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。主题 : 高德地图怎么自定制三种类型的大头针??
级别: 新手上路
可可豆: 105 CB
威望: 105 点
在线时间: 85(时)
发自: Web Page
来源于&&分类
高德地图怎么自定制三种类型的大头针??&&&
项目中要求分别对起点,终点以及途经点自定制大头针,用三种图片分别定义,怎么实现???向大神请教
级别: 侠客
UID: 562955
可可豆: 365 CB
威望: 312 点
在线时间: 186(时)
发自: Web Page
demo中有,你去 demo找找
级别: 新手上路
可可豆: 105 CB
威望: 105 点
在线时间: 85(时)
发自: Web Page
回 1楼(jia8829810) 的帖子
但是那个只有一个类型的
级别: 新手上路
可可豆: 105 CB
威望: 105 点
在线时间: 85(时)
发自: Web Page
回 1楼(jia8829810) 的帖子
我在这里面进行设置不同的类型,为什么刷新地图的时候这三个类型就变成一个了呢??
图片:屏幕快照
13.03.40.png
级别: 骑士
可可豆: 643 CB
威望: 628 点
在线时间: 261(时)
发自: Web Page
给anntation动态添加一个属性来判断
级别: 侠客
UID: 562955
可可豆: 365 CB
威望: 312 点
在线时间: 186(时)
发自: Web Page
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id&MAAnnotation&)annotation{&&&&if ([annotation isKindOfClass:[MyPointAnnotation class]])&&&&{&&&&&&&&MyPointAnnotation*ano=&&&&&&&&static NSString *reuseIndetifier = @&annotationReuseIndetifier&;&&&&&&&&CustomAnnotationView *annotationView = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseIndetifier];&&&&&&&&if (annotationView == nil)&&&&&&&&{&&&&&&&&&&&&annotationView = [[CustomAnnotationView alloc] initWithAnnotation:ano&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&reuseIdentifier:reuseIndetifier];&&&&&&&&}&&&&&&&&annotationView.canShowCallout= YES;&&&&&& //设置气泡可以弹出,默认为NO&&&&&&&&annotationView.busStopCount=(int)_busLineSiteArray.&&&&&&&&annotationView.siteNumber=ano.siteN&&&&&&&&annotationView.centerOffset = CGPointMake(0, 0);&&&&&&&&if ([ano.siteNumber isEqualToString:_selectBusStop]) {&&&&&&&&&&&&annotationView.canShowCallout= YES;&&&&&& //设置气泡可以弹出,默认为NO&&&&&&&&&&&&if ([ano.siteNumber integerValue]==0) {&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&起点激活&];&&&&&&&&&&&&&&&&//&&&&&&&&&&&&}&&&&&&&&&&&&else if ([ano.siteNumber integerValue]==_busLineSiteArray.count-1)&&&&&&&&&&&&{&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&地图终点激活&];&&&&&&&&&&&&}&&&&&&&&&&&&else&&&&&&&&&&&&{&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&地图站点2&];&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&&&}&&&&&&&&else&&&&&&&&{&&&&&&&&&&&&if (ano.isCar) {&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&站内车图标&];&&&&&&&&&&&&}&&&&&&&&&&&&else&&&&&&&&&&&&{&&&&&&&&&&&&&&&&annotationView.canShowCallout= YES;&&&&&& //设置气泡可以弹出,默认为NO&&&&&&&&&&&&&&&&if ([ano.siteNumber integerValue]==0) {&&&&&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&起点&];&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&else if ([ano.siteNumber integerValue]==_busLineSiteArray.count-1)&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&地图终点&];&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&else&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&annotationView.image = [UIImage imageNamed:@&地图站点1&];&&&&&&&&&&&&&&&&}&&&&&&&&&&&&}&&&&&&&&}//&&&&&&&&annotationView.portrait = [UIImage imageNamed:@&hema&];&&&&&&&&&&&&&&&&return annotationV&&&&}&&&&}不好意思。。我看我的代码是自己写的。。。自己添加了一个属性
级别: 新手上路
可可豆: 105 CB
威望: 105 点
在线时间: 85(时)
发自: Web Page
回 4楼(appleeater) 的帖子
怎么动态添加属性?
级别: 新手上路
可可豆: 105 CB
威望: 105 点
在线时间: 85(时)
发自: Web Page
回 5楼(jia8829810) 的帖子
额,方便给个Demo么??谢谢
级别: 侠客
UID: 562955
可可豆: 365 CB
威望: 312 点
在线时间: 186(时)
发自: Web Page
回 7楼(PLU薰衣草) 的帖子
这是我们最近的项目,不方便给demo,就是自定义一个MAPointAnnotation的子类,添加一些你需要的属性,#import &MAMapKit/MAMapKit.h&@interface MyPointAnnotation : MAPointAnnotation@property(nonatomic,copy)NSString*siteN@property(nonatomic,assign)BOOL isC@property(nonatomic,copy)NSString*busI@end这是我的自定义的子类MyPointAnnotation *pointAnnotation = [[MyPointAnnotation alloc] init];pointAnnotation.siteNumber=[NSString stringWithFormat:@&%d&,i];pointAnnotation.title = [_busLineSiteArray stationName];pointAnnotation.coordinate = CLLocationCoordinate2DMake(buslineCoords.latitude, buslineCoords.longitude);[_mapView addAnnotation:pointAnnotation];添加Annotation的时候给siteNum赋值,然后再加上我上次给你发的那个方法判断一下就可以了
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版iphone开发笔记:地图注解(地图上的大头针)
招聘信息:
Cocoa Touch 没有提供地图注解类,只定义了一个 MKAnnotation 协议。要创建地图注解,必须设计符合 MKAnnotation 协议的类,该类需要一个 CLLocationCoordinate2D coordinate 属性,以及 title 和 subtitle 实例方法。
一. 设计注解类:
例,注解(大头针)类:
@interface LocationObject : NSObject
CLLocationCoordinate2D
NSString *_titleS //title值
NSString *_subTitleS
float _ // 经度值
float _ //纬度值
@property (nonatomic, readonly) CLLocationCoordinate2D
@property float _ // 经度值
@property float _ //纬度值
@property (nonatomic, copy) NSString *_titleS //title值
@property (nonatomic, copy) NSString *_subTitleS
- (id) initWithTitle:(NSString *)atitle latitue:(float)alatitude longitude:(float)
---------------------
@implementation LocationObject
@synthesize coordinate,_latitude,_longitude,_titleString,_subTitleS
- (id) initWithTitle:(NSString *)atitle latitue:(float)alatitude longitude:(float)alongitude
if(self=[super init])
self._titleString =
self._latitude =
self._longitude =
- (CLLocationCoordinate2D)
&&& CLLocationCoordinate2D currentC
currentCoordinate.latitude = self._
&&& currentCoordinate.longitude = self._
&&& return currentC
// required if you set the MKPinAnnotationView's "canShowCallout" property to YES
- (NSString *)title
return self._titleS
// optional
- (NSString *)subtitle
&&& return _subTitleS
- (void)dealloc
[_titleString release];
[_subTitleString release];
&&& [super dealloc];
二、创建、添加和删除注解
1、创建注解:
LocationObject *aLocationObject = [[LocationObject alloc]initWithTitle:nameString latitue:[latitudeString floatValue] longitude:[longitudeString floatValue]];
aLocationObject._subTitleString = addressS
2、添加注解:
先构建一个注解数组 NSMutableArray *_mapA
[self._mapAnnotations addObject:aLocationObject];
[self._mapView addAnnotations:self._mapAnnotations];
3、删除注解:
删除注解可执行 removeAnnotation:一次只删除一个注解,或者执行 removeAnnotation:删除一个数组中的所有项。
如果需要使地图视图回到无注解状态,可执行:
[self._mapView removeAnnotations:self._mapView.annotations];
删除其中全部注解,MKMapView 的 annotations 属性获取了所有注解的数组,然后从地图上全部删除。
三、注解视图
注解对象并非视图,是描述注解的抽象类。注解视图是属于 MKAnnotationView 的子类 MKPinAnnotationView,当地图通过 addAnnotation:或 addAnnotations:添加了注解后,MKMapViewDelegate 协议的委托方法 - (void)mapView:(MKMapView *)mapViewdidAddAnnotationViews:(NSArray *)views 就会通知委托,可以在此回调方法里设置注解视图,如设置大头针颜色、添加附属按钮等,例:
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
// Initialize each view
for (MKPinAnnotationView *mkaview in views)
// 当前位置 的大头针设为紫色,并且没有右边的附属按钮
if ([mkaview.annotation.title isEqualToString:@"当前位置"])
mkaview.pinColor = MKPinAnnotationColorP
mkaview.rightCalloutAccessoryView =
// 其他位置的大头针设为红色,右边添加附属按钮
mkaview.pinColor = MKPinAnnotationColorR
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
mkaview.rightCalloutAccessoryView =
四、注解视图 MKPinAnnotationView 的几个属性说明
newAnnotation.animatesDrop = YES;& // 大头针掉落的动画开启,NO-关闭
newAnnotation.canShowCallout=YES;& // 控制轻击按钮是否生成一个注解视图,默认为Yes-开启
newAnnotation.pinColor&&& // 设置大头针颜色,一共有三种颜色:红色(MKPinAnnotationColorRed),绿色(MKPinAnnotationColorGreen),紫色(MKPinAnnotationColorPurple)
五、自动显示注解视图(Callout)
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation
。。。。。。
///// 自动显示 Callout
_myAnnotation =
[self performSelector:@selector(showCallout) withObject:selfafterDelay:0.1];
& return newA
- (void)showCallout {
&&& [self._mapView selectAnnotation:_myAnnotation animated:YES];
MKMapView学习笔记(转)
一.基本知识
&&&& 目前主流的智能手机大部分都支持GoogleMap地图程序,而手机上的地图程序确实能给我们的出行带来很大的方便。在iPhone中利用MapKit框架可以很方便的显示Google地图,并且可以在地图上添加标注。
二.具体介绍
1.MKMapView的显示
(1)创建MKMapView
CGRect rect = CGRectMake(0, 20, 320, 460);
MKMapView *mapView = [[MKMapView alloc] initWithFrame:rect];
(2)设定经纬度
CLLocationCoordinate2D theC
theCoordinate.latitude=24.148926;
theCoordinate.longitude=120.715542;
(3)设定显示范围
MKCoordinateSpan theS
theSpan.latitudeDelta=0.1;
theSpan.longitudeDelta=0.1;
(4)设置地图显示的中心及范围
MKCoordinateRegion theR
theRegion.center=theC
theRegion.span=theS
(5)设置地图显示的类型及根据范围进行显示
[mapView setMapType:MKMapTypeStandard];
[mapView setRegion:theRegion];
完成这些步骤,再把mapView添加到当前view中就可以显示了。
2.在MKMapView上添加标注
(1)和标注相关的类及协议
&&&&&& (a)MKAnnotation Protocol
&&&&&&&&&&&&& 标注必须实现这个协议,有三个属性,coordinate,title和subtitle,其中coordinate属性必须设置。
&&&&&&&&&&&&& @property (nonatomic, readonly) CLLocationCoordinate2D coordinate
&&&& (b)MKAnnotationView
&&&&&&&&&&&&& 设置好Annotation后就可以用这个把标注在地图上显示出来,&
- (id)initWithAnnotation:(id )annotation reuseIdentifier:(NSString *)reuseIdentifier
&&&&&&&&&&&&& 其比较重要的属性有
@property (nonatomic, retain) UIImage *image
自定义在地图上标注的图片
@property (nonatomic) BOOL canShowCallout
设置点击后能否弹出标注
@property (retain, nonatomic) UIView *rightCalloutAccessoryView
property (retain, nonatomic) UIView *leftCalloutAccessoryView
设置在标注的左右边点击后进一步弹出附属的View
(c)MKPinAnnotationView
这是以大头针的方式显示标注,继承自MKAnnotationView,同时添加了两个属性
@property (nonatomic) MKPinAnnotationColor pinColor
设置大头针的颜色,有红绿紫三种颜色可选择
@property (nonatomic) BOOL animatesDrop
设置大头针是否以掉下来的动画方式显示
(2)在地图上添加Annotation的步骤
&&& (a)创建一个实现MKAnnotation协议的类,在该类的初始化函数中给其coordinate属性设置
&&& (b)用上述方法创建Annotation
&&& (c)把创建的Annotation用addAnnotation的方法添加到MapView中
&&& (d)实现MKMapViewDelegate代理,在代理函数
- (MKAnnotationView *)mapView:(MKMapView *)mView viewForAnnotation:(id )annotation中把Annotation以MKPinAnnotationView或MKAnnotationView的方式标注在地图上上显示。
原帖地址:
微信扫一扫
订阅每日移动开发及APP推广热点资讯公众号:CocoaChina
您还没有登录!请或
点击量16272点击量10875点击量8664点击量8017点击量7488点击量7063点击量6588点击量6497点击量5716
&2016 Chukong Technologies,Inc.
京公网安备89搜索 新闻 资讯 游戏
您现在的位置:&&>>&&>>&&>>&&>>&正文
iOS8地图大头针使用技巧&放置大头针方法
编辑:wangqing && 来源:网络 && 发布时间: 10:57:56
  【巴士数码】苹果一直在改善iOS系统自带地图服务,现在和大家分享一个iOS8自带地图的大头针功能使用技巧,说一说iOS8自带地图放置大头针的具体方法技巧。
  苹果在iOS8系统提供了地图应用,方便大家日常使用。在日常使用地图时,有时需要对一些地点进行标注,留作记号,便于下次查看。在iOS8系统自带的地图中,用户可以使用大头针来进行标记。
  具体操作方法如下:
  第一步,进入地图应用后,长按地图中需要标记的位置,即可放置大头针。
  第二步,放置大头针后,即可看到该位置的标记。
  第三步,点击该标记,即可进行查看该处的详细地址、路线规划及看街景地图,还可以创建新联系人等。
  以上就是小编和大家分享的iOS8自带地图大头针使用技巧,教大家iOS8地图放置大头针的方法技巧,不清楚具体操作的话,可以参考一下本教程。
  iOS 8是美国苹果公司为iPhone、iPad、iPod touch设备开发的移动操作系统,于太平洋时间日向用户推送正式版,支持iPhone4S、iPad2、iPod touch5及以后的设备。
  日苹果正式向广大用户们推送了iOS8.3版本的更新,本次升级包含了性能的提升、错误的修复和重新设计了表情符号键盘等多个新功能。本次升级,对于应用的响应、开启,第三方键盘,控制中心等方面,进行了一定的性能升级,尽可能提高果粉们的操作体验。
扫描左侧二维码,可以订阅iPhone中文网官方微信。每天除了推送最新的苹果产品资讯,我们还将不定期举行有奖活动,广大网友可以积极参与,幸运随时会降临!当然,你也可微信搜索“iPhone中文网”或“apple4cn”,关注iPhone中文网官方微信,第一时间获取更多苹果资讯。
iOS越狱破解
苹果产品信息查询
热门新闻排行
皖公网安备05 皖网文许字[3号
TGBUS Corporation, All Rights Reserved}

我要回帖

更多关于 高德地图移除大头针 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信