Created
September 12, 2015 18:00
-
-
Save loic-sharma/823f5377c227481cce20 to your computer and use it in GitHub Desktop.
GeoFire example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func relevantEventsForLocation(location: CLLocation, withBlock: ([Event]) -> ()) { | |
let root = Firebase(url: "https://pikapic.firebaseio.com") | |
let geoFire = GeoFire(firebaseRef: root) | |
var circleQuery = geoFire.queryAtLocation(location, withRadius: 0.6) | |
let span = MKCoordinateSpanMake(0.001, 0.001) | |
let region = MKCoordinateRegionMake(location.coordinate, span) | |
var query = geoFire.queryWithRegion(region) | |
var keys = Array<String>() | |
var events = Array<Event>() | |
query.observeEventType(GFEventTypeKeyEntered, withBlock: { (key: String!, location: CLLocation!) in | |
keys.append(key) | |
}) | |
query.observeReadyWithBlock({ | |
query.removeAllObservers() | |
// TODO convert keys into events. | |
// Call withBlock | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment