Location Module
Quick Answer
The location module lives in src/core/location. It provides current location helpers, background/location subscription helpers, reverse geocoding, and the IMLocationSelectorModal UI used by listing, social, delivery, vendor, and map-based flows.
Source Map
src/core/location
├── IMLocationSelectorModal
├── getAddressFromCoordinates.ts
├── getCurrentLocation.ts
├── subscribeToLocationUpdates.ts
├── utils.ts
└── index.ts
Key runtime dependencies include:
expo-location
react-native-maps
react-native-google-places-autocomplete
Location Picker UI
IMLocationSelectorModal lets the user search for a place, drag a marker on a map, and return a readable address to the parent screen.
<IMLocationSelectorModal
isVisible={locationSelectorVisible}
onCancel={onLocationSelectorClose}
onDone={onLocationSelectorDone}
onChangeLocation={onChangeLocation}
apiKey={googlePlacesApiKey}
/>
Use your own Google Maps and Places API key. Do not ship demo or hard-coded sample keys in production apps.
Native Setup
Before release, verify:
- iOS location usage descriptions in
ios/*/Info.plist; - Android location permissions in
android/app/src/main/AndroidManifest.xml; - Google Maps configuration for iOS and Android if the app renders maps;
- Google Places API is enabled for the API key used by the app;
- API key restrictions match your bundle ID and Android package name.
Backend And Cost Notes
Location can increase third-party API usage. Review:
- Google Maps billing and key restrictions;
- Places autocomplete request volume;
- reverse geocoding request volume;
- Firestore writes if the app stores user locations;
- privacy policy and store disclosures for location collection.
Only request background location if the app feature requires it, such as delivery tracking. Most apps should request foreground location only.
Verification Checklist
Test:
- permission granted;
- permission denied;
- current location lookup;
- Places search;
- marker drag;
- address callback through
onChangeLocation; - final selected address through
onDone; - map rendering on iOS and Android;
- behavior with a restricted or invalid Google API key.
Troubleshooting
| Problem | Fix |
|---|---|
| Map is blank | Check native map setup, API key restrictions, and platform-specific bundle/package configuration. |
| Places search returns no results | Confirm Places API is enabled and the key is valid for the platform. |
| Permission prompt never appears | Check native permission strings and whether permission was previously denied. |
| App crashes on location screen | Confirm useLayoutEffect and React imports are present if the module was customized. |
| Costs spike | Restrict API keys, debounce autocomplete, and avoid unnecessary reverse geocoding loops. |