Skip to content

Commit

Permalink
fix(distance): set default unit so doesn't fail
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati committed Jun 2, 2018
1 parent 5b1402f commit 0001a29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ An assortment of geolocation related tools, all packaged in one easy to use kit.

Static method which returns the distance, in kilometers, between `start` and `end`.

`start` and `end` must be LatLngLiterals `{ lat: 0, lng: 0}`.
`start` and `end` must be LatLngLiterals `{ lat: 0, lng: 0 }`.

There exists an optional third argument, where if the string `'miles'` is inputted, the result returned will be in miles rather than kilometers.

Expand All @@ -24,7 +24,7 @@ const distance: number = Geokit.distance(location1, location2, 'miles'); // dis

Static method which generates the geohash of a point.

`coordinates` must be LatLngLiterals `{ lat: 0, lng: 0}`.
`coordinates` must be LatLngLiterals `{ lat: 0, lng: 0 }`.

There exists an optional second argument of precision, where the hash produced will be as many characters as the number inputted. It defaults to 10.

Expand Down
2 changes: 1 addition & 1 deletion src/geokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Geokit {
* @param unit Unit of distance returned, defaults to Km.
* @returns The distance between two coordinates.
*/
static distance(start: LatLngLiteral, end: LatLngLiteral, unit?: string): number {
static distance(start: LatLngLiteral, end: LatLngLiteral, unit: string = 'km'): number {
const startValid: Error = validateCoordinates(start);
if (startValid instanceof Error) { throw new Error('Start coordinates: ' + startValid.message); }
const endValid: Error = validateCoordinates(end);
Expand Down

0 comments on commit 0001a29

Please sign in to comment.