Skip to content

current-location is a simple and easy-to-use NPM package that helps you find your current location

Notifications You must be signed in to change notification settings

mohammedmishalk/current-location

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Chrome Firefox Safari Opera Edge IE
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>
  );
}

About

current-location is a simple and easy-to-use NPM package that helps you find your current location

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published