Coder Social home page Coder Social logo

google-places-web's People

Contributors

aranda-adapptor avatar brinley avatar dependabot[bot] avatar m4rtinsp avatar mcabs3 avatar renrizzolo avatar steveperkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

google-places-web's Issues

Typescript compiler errors

If I update to the 1.0.0 version and run tsc I get this errors: (I'm using [email protected])

node_modules/google-places-web/dist/google/Places.d.ts:4:24 - error TS2304: Cannot find name 'IGooglePlacesConfig'.

4     constructor(opts?: IGooglePlacesConfig);
                         ~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:5:27 - error TS2304: Cannot find name 'GooglePlacesAutocompleteOpts'.

5     autocomplete: (opts?: GooglePlacesAutocompleteOpts | undefined) => Promise<GooglePlaceAutocompleteResponse>;
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:5:80 - error TS2304: Cannot find name 'GooglePlaceAutocompleteResponse'.

5     autocomplete: (opts?: GooglePlacesAutocompleteOpts | undefined) => Promise<GooglePlaceAutocompleteResponse>;
                                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:6:32 - error TS2304: Cannot find name 'GooglePlacesQueryAutocompleteOpts'.

6     queryautocomplete: (opts?: GooglePlacesQueryAutocompleteOpts | undefined) => Promise<GooglePlaceQueryAutocompleteResponse>;
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:6:90 - error TS2304: Cannot find name 'GooglePlaceQueryAutocompleteResponse'.

6     queryautocomplete: (opts?: GooglePlacesQueryAutocompleteOpts | undefined) => Promise<GooglePlaceQueryAutocompleteResponse>;
                                                                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:7:22 - error TS2304: Cannot find name 'GooglePlacesDetailsOpts'.

7     details: (opts?: GooglePlacesDetailsOpts | undefined) => Promise<GooglePlaceDetailsResponse>;
                       ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:7:70 - error TS2304: Cannot find name 'GooglePlaceDetailsResponse'.

7     details: (opts?: GooglePlacesDetailsOpts | undefined) => Promise<GooglePlaceDetailsResponse>;
                                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:8:27 - error TS2304: Cannot find name 'GooglePlacesNearbySearchOpts'.

8     nearbysearch: (opts?: GooglePlacesNearbySearchOpts | undefined) => Promise<GooglePlaceNearbySearchResponse>;
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:8:80 - error TS2304: Cannot find name 'GooglePlaceNearbySearchResponse'.

8     nearbysearch: (opts?: GooglePlacesNearbySearchOpts | undefined) => Promise<GooglePlaceNearbySearchResponse>;
                                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:9:25 - error TS2304: Cannot find name 'GooglePlacesTextSearchOpts'.

9     textsearch: (opts?: GooglePlacesTextSearchOpts | undefined) => Promise<GooglePlaceTextSearchResponse>;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:9:76 - error TS2304: Cannot find name 'GooglePlaceTextSearchResponse'.

9     textsearch: (opts?: GooglePlacesTextSearchOpts | undefined) => Promise<GooglePlaceTextSearchResponse>;
                                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:10:26 - error TS2304: Cannot find name 'GooglePlacesOptions'.

10     radarsearch: (opts?: GooglePlacesOptions) => Promise<GooglePlaceBaseResponse>;
                            ~~~~~~~~~~~~~~~~~~~

node_modules/google-places-web/dist/google/Places.d.ts:10:58 - error TS2304: Cannot find name 'GooglePlaceBaseResponse'.

10     radarsearch: (opts?: GooglePlacesOptions) => Promise<GooglePlaceBaseResponse>;

but it is fixed if I return to your 0.3.0 version.

Why it can be?

Error: Cannot find module 'superagent' - React

I got that error while importing the package in React using this code :

import Places from 'google-places-web'

Places.apiKey = 'mykey'
Places.debug = true // boolean;

let partialAddress = '1600 Pennsylv'
const radius = 2000
const language = 'en'

// Search with default opts
Places.autocomplete({ input: partialAddress, radius, language })
  .then(results => {
    console.log(results)
    // results array of partial matches
  })
  .catch(e => console.log(e))

image

i tried installing the superagent package but still

Invalid API Key

screen shot 2018-01-26 at 4 55 54 pm

Getting Invalid API key warning despite passing valid Google API Key.

Bundling failed due to dependency issue

It complains about dependency not found when i try to use your project

bundling failed: Error: While trying to resolve module `google-places-web` from file `/Users/aqueelmiqdad/went/src/apis/GooglePlaces.js`, the package `/Users/aqueelmiqdad/went/node_modules/google-places-web/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/aqueelmiqdad/went/node_modules/google-places-web/dist/google-places-web.umd.js`. Indeed, none of these files exist:

  * `/Users/aqueelmiqdad/went/node_modules/google-places-web/dist/google-places-web.umd.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
  * `/Users/aqueelmiqdad/went/node_modules/google-places-web/dist/google-places-web.umd.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
    at ResolutionRequest.resolveDependency (/Users/aqueelmiqdad/went/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:92:15)
    at DependencyGraph.resolveDependency (/Users/aqueelmiqdad/went/node_modules/metro/src/node-haste/DependencyGraph.js:237:485)
    at Object.resolve (/Users/aqueelmiqdad/went/node_modules/metro/src/lib/transformHelpers.js:116:25)
    at dependencies.map.result (/Users/aqueelmiqdad/went/node_modules/metro/src/DeltaBundler/traverseDependencies.js:298:29)
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/aqueelmiqdad/went/node_modules/metro/src/DeltaBundler/traverseDependencies.js:294:16)
    at /Users/aqueelmiqdad/went/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:33
    at Generator.next (<anonymous>)
    at step (/Users/aqueelmiqdad/went/node_modules/metro/src/DeltaBundler/traverseDependencies.js:239:307)
    at /Users/aqueelmiqdad/went/node_modules/metro/src/DeltaBundler/traverseDependencies.js:239:467

Keep getting 'Property 'autocomplete' does not exist on type 'GooglePlaces'.

import Places from 'google-places-web'; Places.apiKey = '...'; let partialAddress = '1600 Pennsylv'; const radius = 2000; const language = 'en'; // Search with default opts Places.autocomplete({ input: partialAddress, radius, language }) .then(results => { // results array of partial matches }) .catch(e => console.log(e));

Compiling with webpack+TypeScript keeps giving:
TS2339: Property 'autocomplete' does not exist on type 'GooglePlaces'.

Pagination

I hope I'm not missing something simple, but is there a way to handle the pagetoken pagination? The API wants the "next_page_token" value from the initial 20 results response to be passed as the "pagetoken" param on the next call. I can't see how to access the "next_page_token" response value. Is there a way to do this? Thanks for any help you can provide.

radius should be optional

requiredKeys: ["location", "radius"]

hi guys i think there is a bug in here you should make radius optional in order to use rankby="distance".

On documentation you guys explicit tell not to use radius on rankby="distance" requests but in this line you are always required it
invalid response

Error: Missing required params: [radius]
    at GooglePlaces._permitParams (/Users/machoph/Projects/docto/docto-backend/node_modules/google-places-web/dist/google/Places.js:74:23)

Need help with getting access to body

So this is what my code looks like:

function search(){
     try {
    const response = places.nearbysearch({
      location: text, // LatLon delimited by ,
      radius: distance,  // Radius cannot be used if rankBy set to DISTANCE
      type: ['cafe','bakery','meal_delivery','meal_takeaway','restaurant'], // Undefined type will return all types
      // rankby: "distance" // See google docs for different possible values
    });

    const { status, results, next_page_token, html_attributions } = response;
    console.log(tester);
    // console.log(test.data.json());
  } catch (error) {
    console.log(error);
  }


 }

In the console, it works great it displays all of the correct results, but I have one problem: getting the response body and storing the results in strings.

I have tried response.results and response.body, response.json(), and quite a few others but the variable returns undefined...
A little help?

Referer Restrictions question

๐Ÿ‘‹Hi and thanks for this library!

I have a general question about referer restrictions on API keys.

For our web project, we have the referer restriction enabled to prevent leaking + unauthorized use of the key.

Thus, when i try to use the same key in ReactNative, I get back:
"API keys with referer restrictions cannot be used with this API."

This got me wondering if it is safe to use the key with this module in our RN app?

I know that the native iOS implementation of google-places does a similar type of "referral restriction" by reading and matching the bundle-id of the app (always unique)

Any thoughts on this?

Thanks again!

CORS error

Not sure why - but when I try and access Place details I am getting a CORS error.

Failed to load https://maps.googleapis.com/maps/api/place/details/json?key=XXXX&placeid=ChIJD3uTd9hx5kcR1IQvGfr8dbk: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

Webpack import

Hello developers,

thanks for the amazing wrapper. Unfortunately, I can't get this to work. I am using webpack and trying to import with ES6.
This is the warning I get from webpack. When I try to import on my vuejs module I get an error and I'm unable to use it. Any ideas?

WARNING in ./node_modules/google-places-web/dist/index.js
33:12-23 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
@ ./node_modules/google-places-web/dist/index.js
@ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}],"react","env","react","stage-2"],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/components/map/MapSearch.vue
@ ./resources/components/map/MapSearch.vue
@ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}],"react","env","react","stage-2"],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/components/map/page/MapContent.vue
@ ./resources/components/map/page/MapContent.vue
@ ./resources/components/home/OrchestraRoutes.js
@ multi ./resources/components/home/OrchestraRoutes.js

WARNING in ./node_modules/google-places-web/dist/index.js
34:17-34 Critical dependency: the request of a dependency is an expression
@ ./node_modules/google-places-web/dist/index.js
@ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}],"react","env","react","stage-2"],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/components/map/MapSearch.vue
@ ./resources/components/map/MapSearch.vue
@ ./node_modules/babel-loader/lib?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}],"react","env","react","stage-2"],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/components/map/page/MapContent.vue
@ ./resources/components/map/page/MapContent.vue
@ ./resources/components/home/OrchestraRoutes.js
@ multi ./resources/components/home/OrchestraRoutes.js
[Browsersync] Reloading Browsers... (buffered 209 events)

WARNING Compiled with 2 warnings 20:13:07

warning in ./node_modules/google-places-web/dist/index.js

33:12-23 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

warning in ./node_modules/google-places-web/dist/index.js

34:17-34 Critical dependency: the request of a dependency is an expression

INVALID_REQUEST error when attempting to use a pagetoken with NearbySearch API

Apologies as I can't really add much more information other than I set these parameters for a follow up call to nearbyplaces and I get back this fairly useless error from their API.

 {
  radius: 50000,
  pagetoken: 'NEXT_TOKEN_FROM_PREVIOUS_CALL',
  location: '23,-110'
}

The API states that all other fields are ignored when making a call with a pagetoken but the library requires that I include location and radius. Tried setting params to only the page token right before the request is made in Places.js before the call to this._googleApiRequest() to no avail.

Import is wrong in docs

I believe

var Places = require('google-places-web')

should be changed to

const Places = require('google-places-web').default

importance being on the .default

thanks for the library!

NearbySearch rankby: distance broken

According to Places Docs, the following applies:

Note that you cannot specify a custom bounds and/or radius if you specify RankBy.DISTANCE

When I try to make a request like this, I am getting an error.
REQUEST:
const response = await Places.nearbysearch({ location: 52.5489798,13.3540563, name: "REWE", type: "supermarket", rankby: "DISTANCE", });
Error: INVALID_REQUEST

However, when calling Google Places API directly, the request is valid and works. This is because radius should not be a required parameter when rankby ist set to "distance".

Unknown Named Module: Axios

Every time I install this library in my react-native app, I am getting the following error when I run it. I am not finding any resources that may help me fix it up.

More than 20 results

Any plans to enable the use of the next_page_token so we can get more than 20 results?

Thanks!

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Just tried installing this and using in a create-react-app 2.0.3 app and got the following errors:

Error: Cannot find module 'axios'
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

As an aside, I'm not sure adding axios as a dependency to this web module is the right approach since it adds a lot of bloat for users not using axios as their http lib. Maybe using fetch, and letting users polyfill for it if needed, would be a better idea?

Using 'textsearch' returns 'Unhandled Promise Rejection'.

Calling the 'textsearch' method is working fine - nothing breaks, however, I am getting a lot of 'YellowBox' warnings in the console.

For every call to this method, the following warning is returned: Unhandled Promise Rejection and then TypeError: cb is not a function.

I am calling the method with a single instance of Places, so something like:

googlePlaces.textsearch({ location: ..., radius: ..., query: ... }).then((results) => {}).catch((error) => {}).

My 'catch' statement is never triggered, but I am getting the warning messages mentioned above. And, for what it is worth, it appears the Promise is handling the Promise Rejection with a catch statement, just that the cb being returned isn't a function.

Thanks in advance ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.