1.0.1 ā€¢ Published 7 years ago

wheres-here v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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