npm package: @abcum/ember-location
Description: A utility for working with geolocation in an Ember.js app.
Author: Tobie Morgan Hitchcock
Latest version: 2.0.3
Deprecated: Package no longer supported. Use github.com/abcum/ascua instead.

# ember-location

A utility for working with geolocation in an Ember.js app.

[![](https://img.shields.io/circleci/project/abcum/ember-location/master.svg?style=flat-square)](https://circleci.com/gh/abcum/ember-location) [![](https://img.shields.io/npm/v/@abcum/ember-location.svg?style=flat-square)](https://www.npmjs.com/package/@abcum/ember-location) [![](https://img.shields.io/badge/ember-2.16.1+-orange.svg?style=flat-square)](https://github.com/abcum/ember-location) [![](https://david-dm.org/abcum/ember-location/status.svg?style=flat-square)](https://david-dm.org/abcum/ember-location) [![](https://david-dm.org/abcum/ember-location/dev-status.svg?style=flat-square)](https://david-dm.org/abcum/ember-location?type=dev) [![](https://img.shields.io/badge/license-MIT-00bfff.svg?style=flat-square)](https://github.com/abcum/ember-location) 

## Usage

### Installation

`ember install @abcum/ember-location`

### Methods

#### find()

The `find` method retrives the location from the browser using the HTML5 Geolocation API. It returns a Ember.RSVP.Promise, which will reject if the HTML5 Geolocation API is not available, or if the current coordinates are not able to be found, and will resolve if the positioning was successful. In addition the current geolocation position is saved to the `current` property.

```js
this.get('location').find({ timeout:5000 }).then(function(result) {
	// Access the user's location using `result` or `this.location.current`
});
```

It accepts an **optional** object as the first argument which can be used to customise the query. If omitted it will default to the values listed here.

```js
{
	enableHighAccuracy: false,
	timeout: Infinity,
	maximumAge: 0
}
```

#### watch()

The `watch` method continually retrieves and tracks the location from the browser using the HTML5 Geolocation API. It returns a Ember.RSVP.Promise, which will reject if the HTML5 Geolocation API is not available, or if the current coordinates are not able to be found, and will resolve if the positioning was successful. In addition the current geolocation position is continually saved to the `current` property.

```js
this.get('location').watch({ timeout:5000 }).then(function(result) {
	// Access the user's location using `result` or `this.location.current`
});
```

It accepts an **optional** object as the first argument which can be used to customise the query. If omitted it will default to the values listed here.

```js
{
	enableHighAccuracy: false,
	timeout: Infinity,
	maximumAge: 0
}
```

### Properties

The `current` property stores the latest positioning data which was retrieved using the HTML5 Geolocation API, an example of which is displayed here.

```js
{
  coords: {
    accuracy: 75,
    altitude: null,
    altitudeAccuracy: null,
    heading: null,
    latitude: 51.165,
    longitude: 0.248,
    speed: null
  },
  timestamp: 1470156731858
}
```

### Examples

Wait for the current position before displaying the route.

```js
export default Ember.Route.extend({
	model() {
		return this.get('location').watch();
	}
})
```

Display the current position on a map in the template using the `current` object.

```hbs
{{example-map lat=location.current.coords.latitude lng=location.current.coords.longitude}}
```

## Development

- `make install` (install bower and ember-cli dependencies)
- `make upgrade` (upgrade ember-cli to the specified version)
- `make tests` (run all tests defined in the package)