Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/browser-location
Get your current location from the Browser.
https://github.com/derhuerst/browser-location
geolocation gps location
Last synced: 6 days ago
JSON representation
Get your current location from the Browser.
- Host: GitHub
- URL: https://github.com/derhuerst/browser-location
- Owner: derhuerst
- License: isc
- Created: 2016-09-08T23:52:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-10T19:10:03.000Z (over 2 years ago)
- Last Synced: 2024-05-01T23:29:03.944Z (7 months ago)
- Topics: geolocation, gps, location
- Language: JavaScript
- Homepage: https://github.com/derhuerst/browser-location
- Size: 37.1 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# *browser-location*
**Get your current location from the Browser**, using the [geolocation Web API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation).
[![npm version](https://img.shields.io/npm/v/browser-location.svg)](https://www.npmjs.com/package/browser-location)
[![build status](https://img.shields.io/travis/derhuerst/browser-location.svg)](https://travis-ci.org/derhuerst/browser-location)
[![dependency status](https://img.shields.io/david/derhuerst/browser-location.svg)](https://david-dm.org/derhuerst/browser-location)
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/browser-location.svg)](https://david-dm.org/derhuerst/browser-location#info=devDependencies)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/browser-location.svg)
[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)See also:
- [`location`](https://github.com/derhuerst/location) for Node.js
- [`isomorphic-location`](https://github.com/derhuerst/isomorphic-location) for Browsers & Node**Help Wanted!** Currently, tests are running with Chrome on Windows, but I'd like to extend them to iOS & Android. Contributions welcome!
## Installing
```shell
npm install @derhuerst/browser-location
```## Usage
```js
const location = require('@derhuerst/browser-location')location((err, loc) => {
if (err) console.error(err)
else console.log(loc)
})
```This will give you something similar to the following:
```js
{
latitude: 52.547172,
longitude: 13.347745,
precision: 65, // in meters
native: true
}
```## API
```js
location([timeout], cb)
````timeout` is in milliseconds, optional and `10 * 1000` by default. `cb(err, loc)` follows the [Node callback convention](https://stackoverflow.com/a/40512067).
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/location/issues).