Skip to content
/ yanix Public

Develop a package that provides easy access to geolocation data and services, such as getting the user's location based on IP address or coordinates, calculating distances between locations, etc.

Notifications You must be signed in to change notification settings

9nxex/yanix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Geolocation API

This package provides functionalities to interact with geolocation data in JavaScript.

Installation

You can install the package via npm:

npm install geolocation-api

Usage

Getting User Location

To get the user's location based on their IP address:

const { getUserLocation } = require('geolocation-api');

getUserLocation().then(location => {
    console.log('User location:', location);
});

The getUserLocation function returns an object containing the user's city, country, and coordinates.

Calculating Distance

To calculate the distance between two sets of coordinates:

const { calculateDistance } = require('geolocation-api');

const coord1 = { lat: 40.7128, lon: -74.006 };
const coord2 = { lat: 34.0522, lon: -118.2437 };

const distance = calculateDistance(coord1, coord2);
console.log('Distance:', distance, 'meters');

The calculateDistance function takes two sets of coordinates (latitude and longitude) as input and returns the distance between them in meters.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Develop a package that provides easy access to geolocation data and services, such as getting the user's location based on IP address or coordinates, calculating distances between locations, etc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published