How to use the expo-location.getCurrentPositionAsync function in expo-location

To help you get started, we’ve selected a few expo-location examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / expo-location_v5.x.x / flow_v0.104.x- / test_expo-location.js View on Github external
it('should raise an error when call function with invalid arguments', () => {
    // $ExpectError: need an object
    getCurrentPositionAsync(11);

    // $ExpectError: `__accuracy` is missing in enum
    getCurrentPositionAsync({ __accuracy: 1 });
  });
});
github flow-typed / flow-typed / definitions / npm / expo-location_v5.x.x / flow_v0.104.x- / test_expo-location.js View on Github external
it('should passes when used properly', () => {
    getCurrentPositionAsync({
      accuracy: Accuracy.High,
    }).then(result => {
      const { coords, timestamp } = result;

      (timestamp: number);

      (coords.latitude: number);
      (coords.speed: number);

      // $ExpectError: check any
      (coords.speed: string);
    });
  });
github calebnance / expo-uber / src / screens / Home.js View on Github external
Permissions.LOCATION
    );
    let finalStatus = existingStatus;

    // ask again to grant locaton permissions (if not already allowed)
    if (existingStatus !== 'granted') {
      const { status } = await Permissions.askAsync(Permissions.LOCATION);
      finalStatus = status;
    }

    // still not allowed to use location?
    if (finalStatus !== 'granted') {
      return;
    }

    const { coords } = await Location.getCurrentPositionAsync();

    this.setState({
      showMap: true,
      userLat: coords.latitude,
      userLon: coords.longitude
    });
  }
github NervJS / taro / packages / taro-rn / src / api / location / index.js View on Github external
return new Promise((resolve, reject) => {
    Location.getCurrentPositionAsync({
      enableHighAccuracy: Boolean(altitude)
    }).then((resp) => {
      const {coords, timestamp} = resp
      const {latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed} = coords
      const res = {
        latitude,
        longitude,
        speed,
        altitude,
        accuracy,
        verticalAccuracy: altitudeAccuracy,
        horizontalAccuracy: null,
        heading,
        timestamp
      }
      success && success(res)
github developmentseed / observe / app / screens / CameraScreen.js View on Github external
async snap () {
    if (this.camera) {
      let { uri } = await this.camera.takePictureAsync()
      const location = await Location.getCurrentPositionAsync({})
      this.setState({
        image: uri,
        location: location
      })
    }
  }
  render () {
github FaridSafi / react-native-gifted-chat / example-expo / mediaUtils.js View on Github external
export async function getLocationAsync(onSend) {
  if (await getPermissionAsync(Permissions.LOCATION)) {
    const location = await Location.getCurrentPositionAsync({})
    if (location) {
      onSend([{ location: location.coords }])
    }
  }
}
github syousif94 / frugalmaps / buncha / utils / Locate.js View on Github external
export default function locate() {
  if (WEB) {
    return Location.getCurrentPositionAsync({
      enableHighAccuracy: false,
      maximumAge: 15 * 60 * 1000
    });
  } else {
    return Location.getLastKnownPositionAsync();
  }
}