Skip to content

Commit e96288b

Browse files
committed
docs: doc improvements
1 parent c74e562 commit e96288b

4 files changed

Lines changed: 233 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
22
.rpt2_cache/
33
dist/
4-
coverage/
4+
coverage/
5+
dochtml/

README.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Realtime Geolocation with Firestore & RxJS
1010
npm install firebase geofirex
1111
```
1212

13+
#### Initialize
14+
1315
The library is a lightweight client for the Firebase SDK that provides tools for handling geolocation data in Firestore.
1416

1517
```ts
@@ -22,6 +24,8 @@ import * as geofirex from 'geofirex';
2224
const geo = geofirex.init(firebase);
2325
```
2426

27+
#### Write Geo Data
28+
2529
First, you'll need to add some geolocation data in your database. A `collection` creates a reference to Firestore (just like the SDK), but with some extra geoquery features. The `geohash` method returns a class that helps you create geolocation data.
2630

2731
```ts
@@ -32,6 +36,8 @@ const point = geo.point(40, -119);
3236
cities.add({ name: 'Phoenix', position: point.data });
3337
```
3438

39+
#### Query Geo Data
40+
3541
Now let's make a query Firestore for _cities.position within 100km radius of a centerpoint_.
3642

3743
```ts
@@ -53,17 +59,62 @@ query.subscribe(console.log);
5359

5460
Better docs soon...
5561

56-
### `init`
62+
### `init(app: FirebaseApp)`
5763

5864
Initializes the GeoFireClient
5965

66+
```ts
67+
import * as firebase from 'firebase/app';
68+
import * as geofirex from 'geofirex';
69+
firebase.initializeApp(yourConfig);
70+
71+
const geo = geofirex.init(firebase);
72+
```
73+
6074
### `collection`
6175

62-
Returns a GeoFireCollectionRef instance
76+
Creates reference to a Firestore collection that can be used to make geo-queries and perform writes If you pass a query, any subsequent geo-queries will be limited to this subset of documents
77+
78+
**Parameters:**
79+
80+
| Param | Type | Description |
81+
| ---------------- | -------- | ---------------------------- |
82+
| path | `string` | path to collection |
83+
| `Optional` query | QueryFn | callback for firestore query |
84+
85+
#### collection.within(center: _GeoFirePoint_, radius: _`number`_, field: _`string`_, opts?: GeoQueryOptions): `Observable`<`object`[]>`
86+
87+
Queries the Firestore collection based on geograpic radius
88+
89+
**Parameters:**
90+
91+
| Param | Type | Default value | Description |
92+
| -------------------- | --------------- | ------------- | --------------------------------------------------------- |
93+
| center | GeoFirePoint | - | the starting point for the query, i.e geo.point(lat, lng) |
94+
| radius | `number` | - | the radius to search from the centerpoint |
95+
| field | `string` | - | the document field that contains the GeoFirePoint data |
96+
| `Default value` opts | GeoQueryOptions | defaultOpts |
97+
98+
**Returns:** `Observable`<`object`[]>
6399

64100
### `point`
65101

66-
Returns a GeoFirePoint instance
102+
Returns a GeoFirePoint allowing you to create geohashes, format data, and calculate relative distance/bearing.
103+
104+
`geo.point(latitude, longitude)`
105+
106+
#### Getters
107+
108+
- `hash` Returns a geohash string at precision 9
109+
- `geoPoint` Returns a Firestore GeoPoint
110+
- `geoJSON` Returns data as a GeoJSON `Feature<Point>`
111+
- `coords` Returns coordinates as `[latitude, longitude]`
112+
- `data` Returns data object suitable for saving to the Firestore database
113+
114+
#### Geo Calculations
115+
116+
- `distance(latitude, longitude)` Haversine distance to a point
117+
- `bearing(latitude, longitude)` Haversine bearing to a point
67118

68119
## Tips
69120

package-lock.json

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"test:watch": "jest --watchAll",
1919
"build": "rollup -c",
2020
"dev": "rollup -c -w",
21-
"publish": ""
21+
"publish": "",
22+
"doc": "typedoc --out dochtml src --excludeExternals --excludePrivate --mode file --theme markdown --mdEngine github"
2223
},
2324
"keywords": [
2425
"rxjs",
@@ -62,6 +63,8 @@
6263
"ts-loader": "3.5.0",
6364
"ts-node": "5.0.1",
6465
"tslint": "5.9.1",
66+
"typedoc": "^0.11.1",
67+
"typedoc-plugin-markdown": "^1.1.13",
6568
"typescript": "2.8.1"
6669
},
6770
"jest": {

0 commit comments

Comments
 (0)