# @abcum/ember-location

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

Latest version **2.0.3** (published 2018-09-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @abcum/ember-location
pnpm add @abcum/ember-location
yarn add @abcum/ember-location
bun add @abcum/ember-location
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2018-09-07 |
| First published | 2017-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^4.5 \|\| 6.* \|\| >= 7.* |
| Dependencies | 1 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tobie Morgan Hitchcock |
| Maintainers | tobiemh |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/@abcum/ember-location
- Repository: https://github.com/abcum/ember-location
- Homepage: https://github.com/abcum/ember-location#readme
- Issues: https://github.com/abcum/ember-location/issues
- npm.io page: https://npm.io/package/@abcum/ember-location

## Dependencies (1)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^6.6.0

## Recent versions

- 2.0.3 (latest) — 2018-09-07
- 2.0.2 — 2018-06-16
- 2.0.1 — 2018-03-25
- 2.0.0 — 2018-01-08
- 1.0.0 — 2017-08-02

## README

# 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)

---
_Source: https://npm.io/package/@abcum/ember-location · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
