Expo

Location Select

Location picker field with device geolocation and reverse geocoding support.

iOSAndroid

Overview

DocyFieldLocationSelect uses community native modules for device-specific location features:

  • @react-native-community/geolocation — Access device GPS to get current coordinates
  • react-native-geocoding — Reverse geocode coordinates to human-readable addresses (requires Google Maps API key)

Without these modules installed, the location picker still works with manual text search and predefined locations — but the "Use Current Location" button will be unavailable.

Installation

# Geolocation (for "Use Current Location" feature)
npx expo install @react-native-community/geolocation

# Reverse geocoding (for converting coordinates to addresses)
npm install react-native-geocoding

Google Maps API Key

Reverse geocoding requires a Google Maps Geocoding API key. Pass it as a prop or set the EXPO_PUBLIC_GOOGLE_MAPS_API_KEY environment variable:

<DocyFieldLocationSelect
  googleMapsApiKey="YOUR_API_KEY"
  // ... other props
/>

Compatibility

ModuleExpo GoDev ClientBare RN
@react-native-community/geolocationNoYesYes (auto-linked)
react-native-geocodingYes (JS only)YesYes

Note: @react-native-community/geolocation requires a development build — it does not work in Expo Go. The component handles this gracefully at runtime.

Usage

import { DocyFieldLocationSelect } from '@/components/docyrus-native/form-fields/docy-field-location-select';

<DocyFieldLocationSelect
  label="Office Location"
  allowCurrentLocation
  showCoordinates
  requestLocationPermission={async () => {
    // Your permission handling logic
    return 'granted';
  }}
  onChange={(location) => console.log(location)}
/>

API Reference

PropTypeDefaultDescription
valueLocationInfo—Current location value
onChange(value: LocationInfo) => void—Called when location changes
placeholderstring'Select location'Placeholder text
allowCurrentLocationbooleantrueShow "Use Current Location" button
showCoordinatesbooleantrueShow coordinates under location items
predefinedLocationsLocationInfo[]Popular citiesCustom location list
requestLocationPermission() => Promise<'granted' | 'denied'>—Permission request callback
googleMapsApiKeystringEXPO_PUBLIC_GOOGLE_MAPS_API_KEYGoogle Maps API key for geocoding

LocationInfo Type

FieldTypeDescription
namestringDisplay name
addressstring?Full address
coordinates{ latitude: number; longitude: number }?GPS coordinates
countrystring?Country name
citystring?City name
regionstring?Region/state
postalCodestring?Postal code
type'current' | 'saved' | 'search'?Location source

On this page