{"id":28092857,"url":"https://github.com/luchermkens/react-native-gplaces","last_synced_at":"2025-05-13T13:49:08.593Z","repository":{"id":57337367,"uuid":"154020131","full_name":"LucHermkens/react-native-gplaces","owner":"LucHermkens","description":"React Native library for utilizing Google's Autocomplete for Places.","archived":false,"fork":false,"pushed_at":"2022-12-06T14:33:50.000Z","size":108,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-03T23:32:02.350Z","etag":null,"topics":["auto","autocomplete","complete","google","gplaces","native","places","react","react-native","react-native-gplaces"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucHermkens.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-21T14:57:17.000Z","updated_at":"2023-12-01T07:18:49.000Z","dependencies_parsed_at":"2023-01-23T08:15:32.400Z","dependency_job_id":null,"html_url":"https://github.com/LucHermkens/react-native-gplaces","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermkens%2Freact-native-gplaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermkens%2Freact-native-gplaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermkens%2Freact-native-gplaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermkens%2Freact-native-gplaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucHermkens","download_url":"https://codeload.github.com/LucHermkens/react-native-gplaces/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253953301,"owners_count":21989813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto","autocomplete","complete","google","gplaces","native","places","react","react-native","react-native-gplaces"],"created_at":"2025-05-13T13:49:07.697Z","updated_at":"2025-05-13T13:49:08.573Z","avatar_url":"https://github.com/LucHermkens.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-gplaces\n\nReact Native library for utilizing Google's Autocomplete for Places.\n\n## Install\n\n**Notice**: Geolocation must be linked, in React Native 0.60+ this is done automatically.\n\n### using npm\n\n```sh\nnpm install --save react-native-gplaces @react-native-community/geolocation\n```\n\n### using yarn\n\n```sh\nyarn add react-native-gplaces @react-native-community/geolocation\n```\n\n## Importing\n\n### ES6\n\nThe module uses an ES6 style export statement, simply use `import` to load the module.\n\n```js\nimport GPlaces from 'react-native-gplaces';\n```\n\n### ES5\n\nIf you're using an ES5 require statement to load the module, please add `default`. Look [here](https://github.com/joltup/rn-fetch-blob/wiki/Trouble-Shooting#rnfetchblobfetch-is-not-a-function) for more detail.\n\n```js\nvar GPlaces = require('react-native-gplaces').default;\n```\n\n## Usage\n\nThis package supports custom queries if you'd like to use them. For searching queries look [here](https://developers.google.com/places/web-service/autocomplete#place_autocomplete_requests) and queries for getting places look [here](https://developers.google.com/places/web-service/details#PlaceDetailsRequests).\n\n### Creating an instance\n\nYou can obtain a Google API key [here](https://developers.google.com/maps/documentation/javascript/get-api-key).\n\n```js\nconst places = new GPlaces({\n  key: 'YOUR_GOOGLE_MAPS_API_KEY' // https://developers.google.com/maps/documentation/javascript/get-api-key\n});\n```\n\n### Search for places\n\n```js\nplaces.search('nemo', {\n  components: 'country:nl',\n  types: 'establishment'\n})\n  .then(r =\u003e {\n    // returns ACResult[]\n  })\n  .catch(console.error)\n```\n\n### Search for places nearby\n\n```js\nplaces.searchNearby('brussel', 2500, {\n  components: 'country:be',\n  types: '(cities)'\n})\n  .then(r =\u003e {\n    // returns ACResult[]\n  })\n  .catch(console.error)\n```\n\n### Get details for a Place\n\n```js\nplaces.getPlaceDetails('ChIJn8N5VRvZxkcRmLlkgWTSmvM', {\n  fields: 'geometry'\n})\n  .then(r =\u003e {\n    // returns PDResult\n  })\n  .catch(console.error)\n```\n\n## API\n\n### `constructor GPlaces(options: Options): GPlaces`\n\nConstructor for creating an instance of the GPlaces class\n\n### `request: (url?: string) =\u003e Promise\u003cany\u003e (@private)`\n\nCalling this method will fetch an URL and return a JSON response\n\n### `autocompleteRequest: (options?: string) =\u003e Promise\u003cACResult[]\u003e (@private)`\n\nCalling this method will fetch and return an array of results\n\n\u003c!-- TODO: document default query --\u003e\n\u003c!-- TODO: recommend debounce --\u003e\n\n### `search: (input?: string, query?: ACQuery | undefined) =\u003e Promise\u003cACResult[]\u003e`\n\nCalling this method will search for places matching the input.\n\n### `searchNearby: (input?: string, radius?: number, query?: ACQuery | undefined) =\u003e Promise\u003cACResult[]\u003e`\n\nCalling this method will search for nearby places matching the input in a given radius.\nThe default radius is 1000m / 1km.\n\n### `getPlaceDetails: (placeid?: string, query?: PDQuery | undefined) =\u003e Promise\u003cPDResult\u003e`\n\nCalling this method will get certain details for a place based on a query.\n\n## Types\n\nFor up-to-date information about Autocomplete queries look [here](https://developers.google.com/places/web-service/autocomplete#place_autocomplete_requests), for Place Details queries look [here](https://developers.google.com/places/web-service/details#PlaceDetailsRequests).\n\n```ts\nexport interface ACQuery {\n  sessiontoken?: string;\n  offset?: number;\n  location?: string;\n  radius?: number;\n  language?: string;\n  types?: string;\n  components?: string;\n  strictbounds?: boolean;\n}\n\nexport interface PDQuery {\n  language?: string;\n  region?: string;\n  sessiontoken?: string;\n  fields?: string;\n}\n\nexport interface Options {\n  key: string;\n}\n\nexport interface MSubstring {\n  length: number;\n  offset: number;\n}\nexport type MSubstrings = Array\u003cMSubstring\u003e\n\nexport interface SFormat {\n  main_text: string;\n  main_text_matched_substrings: MSubstrings;\n  secondary_text: string;\n}\nexport type SFormatting = Array\u003cSFormat\u003e\n\nexport interface Term {\n  offset: number;\n  value: string;\n}\nexport type Terms = Array\u003cTerm\u003e\n\nexport interface ACResult {\n  id: string;\n  place_id: string;\n  reference: string;\n  description: string;\n  matched_substrings: MSubstrings;\n  structured_formatting: SFormatting;\n  terms: Terms;\n  types: Array\u003cstring\u003e;\n}\nexport type ACResults = Array\u003cACResult\u003e\n\nexport type Types = Array\u003cstring\u003e\nexport type HTMLAttrs = Array\u003cstring\u003e\n\nexport interface AddressComponent {\n  long_name: string;\n  short_name: string;\n  types: Types;\n}\nexport type AddressComponents = Array\u003cAddressComponent\u003e\n\nexport interface Photo {\n  height: number;\n  html_attributions: HTMLAttrs;\n  photo_reference: string;\n  width: number;\n}\nexport type Photos = Array\u003cPhoto\u003e\n\nexport interface Location {\n  lat: string;\n  lng: string;\n}\nexport interface Viewport {\n  northeast: Location;\n  southwest: Location;\n}\nexport interface Geometry {\n  location: Location;\n  viewport: Viewport;\n}\n\nexport interface PDResult {\n  address_components: AddressComponents;\n  adr_address: string;\n  formatted_address: string;\n  geometry: Geometry;\n  icon: string;\n  id: string;\n  name: string;\n  photos: Photos;\n  place_id: string;\n  reference: string;\n  scope: string;\n  types: Types;\n  url: string;\n  utc_offset: number;\n  vicinity: string;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluchermkens%2Freact-native-gplaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluchermkens%2Freact-native-gplaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluchermkens%2Freact-native-gplaces/lists"}