@aaxis/react-native-google-places
v0.0.3
Published
Places SDK for React Native
Downloads
16
Readme
@aaxis-internal/react-native-google-places
Places SDK for React Native.
Installation
npm install @aaxis-internal/react-native-google-placesMake sure you have .npmrc configured.
Setup
It need provide your GMSAPIKEY to use this SDK.
for iOS
// AppDelegate.m
@import GooglePlaces;
// ...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
[GMSPlacesClient provideAPIKey:@"APIKEY"];
}for Android
// gradle.properties
GOOGLE_PLACES_API_KEY=APIKEYUsage
Currently, the SDK integrates three methods.
import { findAutocompletePredictions, fetchPlaceFromPlaceID, refreshSessionToken } from "@aaxis-internal/react-native-google-places";
// ...
const predictions = await findAutocompletePredictions("apple park");
const [firstResult] = predictions;
const placeInfo = await fetchPlaceFromPlaceID(firstResult.placeID);findAutocompletePredictions
findAutocompletePredictions(query: string, filters: GMSAutocompleteFilter): Promise<GMSPrediction[]>;query
Find Autocomplete predictions from text query.
**filters **
Set up filters for autocomplete requests.
GMSAutocompleteFilter
type: string
The type filter applied to an autocomplete request to restrict results to different types.
It can be one of address, city, establishment, geocode, region, noFilter.
country: string
The country to restrict results to, ignored if the countries property is set.
This should be a ISO 3166-1 Alpha-2 country code (case insensitive). If nil, no country filtering will take place.
countries: string[]
The countries to restrict results to, overrides the country property if that is set.
origin: Coordinate
The straight line distance origin location for measuring the straight line distance between the origin location and autocomplete predictions.
locationBias: GMSCoordinateBounds
The optional location bias to prefer place results near the location.
locationRestriction: GMSCoordinateBounds
The optional location restriction to limit the place results to.
fetchPlaceFromPlaceID
fetchPlaceFromPlaceID(placeID: string,placeFields: GMSPlaceField[]): Promise<GMSPlace>placeID
The place ID to lookup.
**placeFields **
The fields represent individual information that can be requested for a GMSPlace object.
If no request fields are set, the GMSPlace object will contain all information.
refreshSessionToken
By default, this SDK will automatically generate the SessionToken.
If findAutocompletePredictions is called multiple times to obtain the list but fetchPlaceFromPlaceID method is not called to obtain the details, a new SessionToken will not be generated. You need to manually call this method to create a new SessionToken.
More information about [SessionToken](Session Tokens | Places SDK for iOS | Google Developers).
