3.0.8 β€’ Published 9 months ago

react-native-place-picker v3.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago
  • 🎨 Theme customization.
  • πŸ“± UI written natively.
  • πŸ—ΊοΈ Location reverse-geocoding (coordinate -> address).
  • πŸ” Searchable (users can search for location).
  • πŸ“ Device location.
  • βš™οΈ Fully configurable.
  • πŸ—οΈ Supporting Turbo Modules (New Arch) with backward compatibility.
  • ⚑ Renders on top of the app (Blazing Fast).
  • πŸ“ Well typed.
  • πŸ“¦ Significantly small package.
  • πŸ”— No peer dependencies except React and React-Native [1].

How is it working?

This plugin is built only by create native page UIViewController for iOS or Activity for Android. and present the page in front of React Native Application without any special dependencies just native code

Installation

npm install react-native-place-picker
# or
yarn add react-native-place-picker
# or
pnpm add react-native-place-picker
# or
bun add react-native-place-picker

Expo

  • You need to add expo-dev-client and run expo run:ios or expo run:android

Info Expo managed app not supported 🚧

iOS

  • If you want to enable user current location button you have to add this to your Info.plist
<key>NSLocationWhenInUseUsageDescription</key>
<string>YOUR_PURPOSE_HERE</string>

Android ⚠️

  • Add to your AndroidManifest.xml you Google Map API Key or your application will crash
<meta-data
   android:name="com.google.android.geo.API_KEY"
   android:value="YOUR_KEY" />

Request

import { pickPlace } from "react-native-place-picker";

pickPlace({
  enableUserLocation: true,
  enableGeocoding: true,
  color: "#FF00FF",
  //...etc
})
  .then(console.log)
  .catch(console.log);

// or

pickPlace().then(console.log).catch(console.log);

Result

{
    /**
     * @description Selected coordinate.
     */
    coordinate: PlacePickerCoordinate;
    /**
     * @description Geocoded address for selected location.
     * @if `enableGeocoding: true`
     */
    address?: PlacePickerAddress;
    /**
     * @description Did cancel the place picker window without selecting.
     */
    didCancel: boolean;
}

PlacePickerOptions

PropertyTypeDescriptionDefault
presentationStylePlacePickerPresentationStyle | stringPresentation style of the place picker window. iOS only'fullscreen'
titlestringThe title of the place picker window.'Choose Place'
searchPlaceholderstringPlaceholder for the search bar in the place picker window.'Search...'
colorstringPrimary color of the theme (map pin, shadow, etc.).'#FF0000'
contrastColorstringContrast color for the primary color.'#FFFFFF'
localestringLocale for the returned address.'en-US'
initialCoordinatesPlacePickerCoordinateInitial map position.{ latitude: 25.2048, longitude: 55.2708 }
enableGeocodingbooleangeocoding for the selected address.true
enableSearchbooleansearch bar for searching specific positions.true
enableUserLocationbooleancurrent user position button. Requires setup.true
enableLargeTitlebooleanlarge navigation bar title of the UIViewController. iOS onlytrue
rejectOnCancelbooleanReject and return nothing if the user dismisses the window without selecting a place.true

PlacePickerPresentationStyle

Enum ValueDescription
modalPresentation style as a modal window.
fullscreenPresentation style in fullscreen mode.

PlacePickerAddress

PropertyTypeDescription
namestringName of the location.
streetNamestringStreet name of the address.
citystringCity of the address.
statestringState of the address.
zipCodestringZip code of the address.
countrystringCountry of the address.

PlacePickerCoordinate

PropertyTypeDescription
latitudenumberLatitude of the location.
longitudenumberLongitude of the location.

PlacePickerResults

PropertyTypeDescription
coordinatePlacePickerCoordinateSelected coordinate.
addressPlacePickerAddressGeocoded address for selected location (if enableGeocoding).
didCancelbooleanIndicates if the place picker was canceled without selecting.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

3.0.4

9 months ago

3.0.3

9 months ago

3.0.2

9 months ago

3.0.1

9 months ago

3.0.8

9 months ago

3.0.7

9 months ago

3.0.6

9 months ago

3.0.5

9 months ago

3.0.0

9 months ago

2.7.0

2 years ago

2.6.0

2 years ago

2.2.0

3 years ago

2.5.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago