Git Product home page Git Product logo

Comments (3)

vasilenkoigor avatar vasilenkoigor commented on September 22, 2024

@ppamorim Hey, you can take items inside cluster on delegate methods of map view like this: didSelectAnnotation, after that, you can take ABFClusterAnnotation and inside annotation will be array with SafeRealmObjects

from abfrealmmapview.

bigfish24 avatar bigfish24 commented on September 22, 2024

@ppamorim I added some helper methods to make it easier to get your objects. Check out this release: 55ade66

The example apps for Swift and Objective-C demonstrate how you can use the class method safeObjectsForClusterAnnotationView: on ABFClusterAnnotationView to retrieve the safe objects in the cluster from the annotation return in the MKMapViewDelegate mapView:didSelectAnnotationView:

Objective-C

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    NSArray<ABFLocationSafeRealmObject *> *safeObjects = [ABFClusterAnnotationView safeObjectsForClusterAnnotationView:view];

    ABFRestaurantObject *firstObject = safeObjects.firstObject.RLMObject;

    NSLog(@"First Object: %@",firstObject.name);
    NSLog(@"Cluster Count: %lu",safeObjects.count);
}

Swift

func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView) {
        if let safeObjects = ABFClusterAnnotationView.safeObjectsForClusterAnnotationView(view) {

            if let firstObject = safeObjects.first?.toObject(ABFRestaurantObject) {
                print("First Object: \(firstObject.name)")
            }

            print("Count: \(safeObjects.count)")
        }
    }

from abfrealmmapview.

ppamorim avatar ppamorim commented on September 22, 2024

@bigfish24 I noticed that RealmMapView-Swift, at line 92, needs to change this line to work:

For this:

#import <RealmMapView/RealmMapView.h>

To this:

#import <RealmMapView/RealmMapView-Swift.h>

Update:

The method toObject not exist. Is it correct? I`m using Swift 2.

from abfrealmmapview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.