|
1 | 1 | # GeoFire for JavaScript — Realtime location queries with Firebase |
2 | 2 |
|
3 | 3 | [](https://travis-ci.org/firebase/geofire-js) |
4 | | -[](https://coveralls.io/r/firebase/geofire-js) |
| 4 | +[](https://coveralls.io/github/firebase/geofire-js?branch=master) |
5 | 5 | [](http://badge.fury.io/gh/firebase%2Fgeofire-js) |
6 | 6 |
|
7 | 7 | GeoFire is an open-source library that allows you to store and query a set of keys based on their |
@@ -50,56 +50,35 @@ using Security and Firebase Rules. |
50 | 50 |
|
51 | 51 | ## Upgrading GeoFire |
52 | 52 |
|
53 | | -### Upgrading from GeoFire 2.x.x to 3.x.x |
54 | | - |
55 | | -GeoFire 3.x has the same API as 2.x but uses a different underlying data structure to store its |
56 | | -location data. If you are currently using 2.x and want to upgrade to 3.x, you must run the |
57 | | -[GeoFire 3.x migration script](https://github.com/firebase/geofire-js/blob/master/migration/migrateToV3.js) |
58 | | -on your Firebase database. This Node.js script only needs to be run one time and should take only a few seconds |
59 | | -to minutes depending on the size of your data. To run the script, copy the files in this repo's |
60 | | -`/migration/` folder to your machine and run the following commands: |
61 | | - |
62 | | -```bash |
63 | | -$ npm install # install local npm dependencies |
64 | | -$ node migrateToV3.js # display usage instructions |
65 | | -``` |
66 | | - |
67 | | -### Upgrading from GeoFire 3.0.x to 3.1.x |
68 | | - |
69 | | -With the release of GeoFire 3.1.0, this library now uses [the new query functionality found in |
70 | | -Firebase 2.0.0](https://www.firebase.com/blog/2014-11-04-firebase-realtime-queries.html). As a |
71 | | -result, you will need to upgrade to Firebase 2.x.x and add a new `.indexOn` rule to your Security |
72 | | -and Firebase Rules to get the best performance. You can view [the updated rules here](./examples/securityRules/rules.json) |
73 | | -and [read our docs for more information about indexing your data](https://www.firebase.com/docs/security/guide/indexing-data.html). |
| 53 | +Using an older version of GeoFire and want to upgrade to the latest version? Check out our |
| 54 | +[migration guides](./migration) to find out how! |
74 | 55 |
|
75 | 56 |
|
76 | 57 | ## Downloading GeoFire |
77 | 58 |
|
78 | 59 | In order to use GeoFire in your project, you need to include the following files in your HTML: |
79 | 60 |
|
80 | 61 | ```html |
81 | | -<!-- RSVP --> |
82 | | -<script src="rsvp.min.js"></script> |
83 | | - |
84 | 62 | <!-- Firebase --> |
85 | | -<script src="https://cdn.firebase.com/js/client/2.2.5/firebase.js"></script> |
| 63 | +<script src="https://cdn.firebase.com/js/client/2.4.1/firebase.js"></script> |
86 | 64 |
|
87 | 65 | <!-- GeoFire --> |
88 | | -<script src="https://cdn.firebase.com/libs/geofire/3.2.4/geofire.min.js"></script> |
| 66 | +<script src="https://cdn.firebase.com/libs/geofire/4.0.0/geofire.min.js"></script> |
89 | 67 | ``` |
90 | 68 |
|
91 | 69 | Use the URL above to download both the minified and non-minified versions of GeoFire from the |
92 | 70 | Firebase CDN. You can also download them from the |
93 | 71 | [releases page of this GitHub repository](https://github.com/firebase/geofire-js/releases). |
94 | | -[Firebase](https://www.firebase.com/docs/web/quickstart.html?utm_source=geofire-js) and |
95 | | -[RSVP](https://github.com/tildeio/rsvp.js/) can be downloaded directly from their respective websites. |
96 | 72 |
|
97 | | -You can also install GeoFire via npm or Bower and its dependencies will be downloaded automatically: |
| 73 | +You can also install GeoFire via npm or Bower. If downloading via npm, you will have to install |
| 74 | +Firebase separately (because it is a peer dependency to GeoFire): |
98 | 75 |
|
99 | 76 | ```bash |
100 | | -$ npm install geofire --save |
| 77 | +$ npm install geofire firebase --save |
101 | 78 | ``` |
102 | 79 |
|
| 80 | +On Bower, the Firebase dependency will be downloaded automatically: |
| 81 | + |
103 | 82 | ```bash |
104 | 83 | $ bower install geofire --save |
105 | 84 | ``` |
@@ -393,9 +372,13 @@ var distance = GeoFire.distance(location1, location2); // distance === 12378.53 |
393 | 372 |
|
394 | 373 | ## Promises |
395 | 374 |
|
396 | | -GeoFire uses promises when writing and retrieving data. Promises represent the result of a potentially long-running operation and allow code to run asynchronously. Upon completion of the operation, the promise will be "resolved" / "fulfilled" with the operation's result. This result will be passed to the function defined in the promise's `then()` method. |
| 375 | +GeoFire uses promises when writing and retrieving data. Promises represent the result of a potentially |
| 376 | +long-running operation and allow code to run asynchronously. Upon completion of the operation, the |
| 377 | +promise will be "resolved" / "fulfilled" with the operation's result. This result will be passed to |
| 378 | +the function defined in the promise's `then()` method. |
397 | 379 |
|
398 | | -GeoFire uses the lightweight RSVP.js library to provide an implementation of JavaScript promises. If you are unfamiliar with promises, please refer to the [RSVP.js documentation](https://github.com/tildeio/rsvp.js/). Here is a quick example of how to consume a promise: |
| 380 | +If you are unfamiliar with promises, check out [this blog post](http://www.html5rocks.com/en/tutorials/es6/promises). |
| 381 | +Here is a quick example of how to consume a promise: |
399 | 382 |
|
400 | 383 | ```JavaScript |
401 | 384 | promise.then(function(result) { |
|
0 commit comments