Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
expo-location
Advanced tools
Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.
The expo-location package provides an API to access and manage the device's location services. It allows you to get the current location, watch for location changes, and geocode or reverse geocode locations.
Get Current Location
This feature allows you to get the current location of the device. The code sample demonstrates how to request permission to access location services and then retrieve the current position.
```javascript
import * as Location from 'expo-location';
async function getCurrentLocation() {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
console.log('Permission to access location was denied');
return;
}
let location = await Location.getCurrentPositionAsync({});
console.log(location);
}
```
Watch Location Changes
This feature allows you to watch for location changes. The code sample demonstrates how to request permission and then set up a watcher that logs the location every time it changes.
```javascript
import * as Location from 'expo-location';
async function watchLocation() {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
console.log('Permission to access location was denied');
return;
}
Location.watchPositionAsync({
accuracy: Location.Accuracy.High,
timeInterval: 1000,
distanceInterval: 1,
}, (location) => {
console.log(location);
});
}
```
Geocoding
This feature allows you to convert an address into geographic coordinates. The code sample demonstrates how to use the geocodeAsync method to get the coordinates of a given address.
```javascript
import * as Location from 'expo-location';
async function geocodeAddress(address) {
let geocode = await Location.geocodeAsync(address);
console.log(geocode);
}
```
Reverse Geocoding
This feature allows you to convert geographic coordinates into a human-readable address. The code sample demonstrates how to use the reverseGeocodeAsync method to get the address of a given set of coordinates.
```javascript
import * as Location from 'expo-location';
async function reverseGeocodeLocation(latitude, longitude) {
let reverseGeocode = await Location.reverseGeocodeAsync({ latitude, longitude });
console.log(reverseGeocode);
}
```
The react-native-geolocation-service package provides similar functionality to expo-location, allowing you to get the current location, watch for location changes, and more. It is a more direct wrapper around the native geolocation APIs and may offer more control and customization options.
The react-native-location package offers similar features to expo-location, including getting the current location and watching for location changes. It also provides additional features like background location updates, which can be useful for certain types of applications.
The react-native-maps package is primarily used for rendering maps, but it also includes location tracking features. It can be a good choice if you need both mapping and location services in your application.
Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.
This package is pre-installed in managed Expo projects. You may skip the rest of the installation guide if this applies to you.
For bare React Native projects, you must ensure that you have installed and configured the @unimodules/core
package before continuing.
npm install expo-location
Add the dependency to your Podfile
and then run pod install
.
pod 'EXLocation', path: '../node_modules/expo-location/ios'
android/settings.gradle
:include ':expo-location'
project(':expo-location').projectDir = new File(rootProject.projectDir, '../node_modules/expo-location/android')
android/app/build.gradle
:api project(':expo-location')
MainApplication.java
, import the package and add it to the ReactModuleRegistryProvider
list:import expo.modules.location.LocationPackage;
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(Arrays.<Package>asList(
// Your other packages will be here
new LocationPackage()
), Arrays.<SingletonModule>asList());
Contributions are very welcome! Please refer to guidelines described in the contributing guide.
FAQs
Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.
The npm package expo-location receives a total of 101,427 weekly downloads. As such, expo-location popularity was classified as popular.
We found that expo-location demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 32 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.