简体   繁体   English

如何对CEMarkerGroup中的所有CEMarker执行操作

[英]How to perform an action on all CEMarker's in a CEMarkerGroup

I've setup CEMarkerGroup's according to my data, and have successfully displayed them. 我已经根据我的数据设置了CEMarkerGroup,并成功显示了它们。 According to Citymaps' documentation , they indicate the following: 根据Citymaps的文档 ,它们指示以下内容:

USING A MARKER GROUP Marker groups allow you to organize your markers and perform functions on all markers in the group simultaneously, and also perform certain operations which you would need to implement yourself otherwise. 使用MARKER GROUP标记组允许您组织标记并同时在组中的所有标记上执行功能,还可以执行某些操作,而这些操作可能需要自己实施。

However, there don't appear to be any exposed class or instance methods that allow action on a particular group. 但是,似乎没有任何公开的类或实例方法允许对特定组执行操作。 Below, I've setup code 在下面,我已经设置了代码

CEMarkerGroup *grpCondo  = [self.mapView markerGroupWithName:@"grpCondo"];
CEMarkerGroup *grpRental = [self.mapView markerGroupWithName:@"grpRental"];
CEMarkerGroup *grpCoOp   = [self.mapView markerGroupWithName:@"grpCoOp"];
CEMarkerGroup *grpCondop = [self.mapView markerGroupWithName:@"grpCondop"];

Later, as I loop through the list of markers I'm adding, I specify the group based on a category ( cat ) value. 稍后,当我遍历要添加的标记列表时,我将根据类别( cat )值指定组。

if ([cat isEqualToString:@"Condo"]) {
    [grpCondo  addMarker:marker];
}
if ([cat isEqualToString:@"Condop"]) {
    [grpCondop addMarker:marker];
}
if ([cat isEqualToString:@"Rental Unit"]) {
    [grpRental addMarker:marker];
}
if ([cat isEqualToString:@"Co-op"]) {
    [grpCoOp   addMarker:marker];
}

These groups, already associated with my map object, display fine, but I cannot find any way to act on these individual groups (eg, hide a group, show a group, etc.) Any thoughts out there? 这些已经与我的地图对象相关联的组显示正常,但是我找不到对这些单个组执行操作的任何方式(例如,隐藏组,显示组等)。在那里有什么想法吗?

Thanks! 谢谢!

I am a developer at Citymaps. 我是Citymaps的开发人员。

CEMarkerGroup is rather bare, and for the most part just a way to organize where your objects are. CEMarkerGroup相当裸露,并且在大多数情况下只是一种组织对象所在位置的方法。 The only batch operation we have a on a marker group right now is to remove all markers in that group from the map. 现在,标记组上唯一的批处理操作是从地图中删除该组中的所有标记。 We also have the collision detection feature, which I saw your other post on. 我们还具有碰撞检测功能,我在您的其他文章中也看到过。

CEMarkerGroup does provide readonly access to its markers, if you want to perform some action to each CEMarker in the group. 如果要对组中的每个CEMarker执行某些操作,CEMarkerGroup确实提供对其标记的只读访问权限。

EDIT: To answer your comment, here is a code sample of how to toggle markers in a marker group. 编辑:要回答您的评论,这是有关如何在标记组中切换标记的代码示例。

    // This would be your toggled value
    BOOL showRentals = YES;
    for(CEMarker *rentalMarker in grpRental.markers) {
        // This property is not yet exposed. This would have the marker automatically fade in or out based on fadeTime.
        //rentalMarker.hidden = !showRentals;

        // You can use this as a proof of concept
        rentalMarker.alpha = showRentals ? 1.f : 0.f;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM