简体   繁体   中英

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. According to Citymaps' documentation , they indicate the following:

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.

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.

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.

CEMarkerGroup is rather bare, and for the most part just a way to organize where your objects are. 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.

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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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