wheres-here

1.0.1 • Public • Published

Where is here?

license npm Bower Travis ESLint Gluons

🌏 Promisified Geolocation

Get current geolocation by Geolocation API as Promise.

Installation

Via Bower:

bower install wheres-here

Via NPM:

NPM

npm install wheres-here

Or Yarn:

yarn add wheres-here

Usage

You can bundle wheres-here with webpack for using in browser.

const here = require('wheres-here');
 
here().then(position => {
    let lat = position.coords.latitude;
    let lng = position.coords.longitude;
    console.log(`I'm at ${lat}${lng}.`); // Somewhere on the Earth.
}).catch(err => {
    console.error(err); // Oh! It's error.
});

Or directly import to your webpage.

You can use unpkg CDN:

https://unpkg.com/wheres-here
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://unpkg.com/wheres-here"></script> 
</head>
<body>
    <script>
        here().then(p => {
            console.log(p);
        }).catch(e => {
            console.error(e);
        });
    </script> 
</body>
</html>

API

here([options])

options

Type: PositionOptions
Return: Promise

Options for Geolocation.getCurrentPosition()

Package Sidebar

Install

npm i wheres-here

Weekly Downloads

4

Version

1.0.1

License

MIT

Last publish

Collaborators

  • illuminator