如何在Google Map iOS SDK中获得特定的标记ID [英] How to get particular Marker id in Google Map iOS SDK

查看:271
本文介绍了如何在Google Map iOS SDK中获得特定的标记ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google地图iOS sdk上工作。这里我在不同的位置坐标中创建多个标记。



现在我需要为所有标记添加标识符,例如TAG,以针对特定标记执行操作。



如果TAG或其他标识符选项在google map iOS sdk中不可用,请告诉我如何将其归档。



解决方案

我所做的只是继承GMSMarker,然后向其中添加我需要的任何数据,

  @interface ATGoogleMapsSelectiveMarker:GMSMarker 

@属性(非原子)int markerID;
@property(nonatomic)int order;
@property(强,非原子)NSObject * referenceObject;
@property(nonatomic)BOOL selected;

@end

编辑:

我认为这很明显,但我会继续讨论如何获取数据......当您创建标记并将其添加到地图中时,您将创建ATGoogleMapsSelectiveMarker并在填充它之后将其添加到地图中用你需要的一切,然后你注册任何你想要的类作为实现GMSMapViewDelegate的代理,并且你实现了这个方法
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ - $(BOOL )mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
//这里您确定您的标记对象的类型是ATGoogleMapsSelectiveMarker,但它不会损害双重检查
如果([标记isKindOfClass:[ATGoogleMapsSelectiveMarker class]]){
ATGoogleMapsSelectiveMarker * parsedMarker =(ATGoogleMapsSelectiveMarker *)marker;
NSLog(@%d,parsedMarker.markerId);
}

return YES;
}


I am working on google map iOS sdk. Here I create multiple markers in separate location co-ordinates.

Now I need to add identifier such like TAG for all markers to perform action for particular marker.

If TAG or some other identifier option is not available in google map iOS sdk, please suggest me how to archive it.

Thanks in Advance.

解决方案

What I do is that I simply inherit the GMSMarker and add whatever data I need to it like this, I guess this is the best and easiest option you have.

@interface ATGoogleMapsSelectiveMarker : GMSMarker

@property (nonatomic) int markerID;
@property (nonatomic) int order;
@property (strong, nonatomic) NSObject* referenceObject;
@property (nonatomic) BOOL selected;

@end

EDIT:

I thought it is clear but I'll continue on how to get the data... When you create your markers and add them to the map, you create ATGoogleMapsSelectiveMarker and add it to the map after you fill it with everything you need, then you register any class you want as a delegate which implements GMSMapViewDelegate and you implement this method

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
    // Here you are sure that your marker object is of type ATGoogleMapsSelectiveMarker but it won't harm to double check
   if ([marker isKindOfClass:[ATGoogleMapsSelectiveMarker class]]) {
       ATGoogleMapsSelectiveMarker* parsedMarker = (ATGoogleMapsSelectiveMarker*)marker;
       NSLog(@"%d", parsedMarker.markerId);
   }

    return YES;
}

这篇关于如何在Google Map iOS SDK中获得特定的标记ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆