current-location-geo
v1.1.5
Published
current-location-geo(geo-finder) is a simple and easy-to-use NPM package that helps you find your current location
Downloads
239
Maintainers
Readme
current-location-geo
A package for retrieving the current geolocation and address information.
Features
- To get Current-location Of the User
- You Can Tag location with Images
- You Can Get Longitude & Latitude
Browser Support
| | | | | | --- | --- | --- | --- | --- | --- | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
Installing
Package manager
Using npm:
$ npm install current-location-geo
Usage
Here's an example of how to use the getLocation
function in a React component:
Once the package is installed, you can import the library using import
or require
approach:
import { getLocation } from 'current-location-geo';
getLocation(function (err, position) {
if (err) {
console.error('Error:', err);
} else {
console.log('Latitude:', position.latitude);
console.log('Longitude:', position.longitude);
console.log('Address:', position.address);
}
});
Example in react js :
import React, { useEffect } from 'react';
import { getLocation } from 'current-location-geo';
export default function App() {
useEffect(() => {
getLocation(function (err, position) {
if (err) {
console.error('Error:', err);
} else {
console.log('Latitude:', position.latitude);
console.log('Longitude:', position.longitude);
console.log('Address:', position.address);
}
});
}, []);
return (
<div className="App">
<h1>Hello World</h1>
</div>
);
}