Coder Social home page Coder Social logo

node-google-places's People

Contributors

jpowers avatar mheadd avatar shfx 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-google-places's Issues

Is this module still maintained?

We would love to use the module if it is still maintained. Currently even the example provided fails -- are there plans to revive the project?

Sensor parameter is no longer required

"The Google Places API previously required that you include the sensor parameter to indicate whether your application used a sensor to determine the user's location. This parameter is no longer required." Source

I can do a separate PR from #11 to address this.

GET / is fetched with node v0.10

I'm not really sure what the underlying issue is. I'm on node 0.10.40 and while the tests pass, I always get {'status_code': 500, 'status_text': 'JSON Parse Failed'} as a response for the autocomplete endpoint. After digging in, it's because / is being fetched, not the autocomplete endpoint and Google returns a 404.

I have a hunch the issue is with different versions of packages. There's no specific versions specified in the package.json so installing it now or in the future could affect the module's behavior.

get error with example

$ ./google 
search:  []

/Users/user/projects/weed.uy/google:11
  places.details({reference: response.results[0].reference}, function(err, res
                                                ^
TypeError: Cannot read property 'reference' of undefined
    at /Users/user/projects/weed.uy/google:11:49
    at IncomingMessage.<anonymous> (/Users/user/projects/weed.uy/node_modules/google-places/lib/google-places.js:82:11)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickCallback (node.js:415:13)```

Question? Browser-based issue with CORS

Trying to call places.autocomplete from a browser app (vue.js). Sorry if this turns out to be a question rather than an issue,.

Here's the code:

import Multiselect from 'vue-multiselect';
import debounce from 'lodash/debounce';
import cloneDeep from 'lodash/cloneDeep'
var GooglePlacesAPI = require('google-places');

var placeApi;
var vm;

module.exports = {
    name: "GooglePlaces",
    components: {
        Multiselect
    },
    props: {
        prop_id: String,
        value: Object
    },
    data: function () {
        return {
            places: [],
            selectedPlace: {},
            isLoading: false,
            resultCount: 0,
            resultIndex: 0
        };
    },
    created: function () {
        vm = this;
        placeApi = new GooglePlacesAPI('xxx');  //todo restrict
        if (typeof vm.value === 'undefined') { return; }
        vm.$set(vm, 'selectedPlace', cloneDeep(vm.value));
    },
    methods: {
        googlePlaceSearch: debounce(searchString => {
            if (searchString.length < 3) {
                return;
            }
            vm.isLoading = true;
            vm.resultCount = 0;
            placeApi.autocomplete({ input: searchString, types: "(Regions)"}, vm.googlePlaceCallback);
        }, 500),
        googlePlaceCallback: function (err, response) {
            if (err) {
                console.log(err);
            }
            else {
                places = [];
                console.log("autocomplete: ", response.predictions);
                vm.getPlaces(err, response);
            }
        },
        getPlaces: function (err, response) {
            for (var index in response.predictions) {
                placesApi.details({ reference: response.predictions[index] }, vm.addPlace);
            }
        },
        addPlace: function (err, response) {
            if (err) {
                console.log(err);
            }
            else {
                places.push(response.result);
            }
            if (resultCount === resultIndex + 1) {
                vm.isLoading = false;
                vm.resultIndex = 0;
                return;
            }
            vm.resultIndex++;
        },
        limitText: function (count) {
            return `and ${count} other places`
        },
        placeChanged: function (newValue, id) {
            //vm.$set(vm, 'selectedPlace', newValue); //handled by v-model
            vm.$emit('input', newValue, id); //return as event per unidirectional data flow
        },
    }
};

Chrome is complaining:

Fetch API cannot load https://maps.googleapis.com/maps/api/place/autocomplete/json?input=vermont&types=(Regions)&language=en&sensor=false&key=xxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

More code examples with simple console based apps

I loved this module . Would love to add more examples with illustrations . Example with detailed procedure to add API keys from google API console to developing full fledged applications using the module and add them to the example collection . If that sounds cool ill be sending pull requests to repo.

Dependency issue when installing with yarn

This module has not been updated in a long time.
@jpowers are you accepting PRs?

I encountered this error with yarn

yarn install v1.3.2
[1/5] ๐Ÿ”  Validating package.json...
[2/5] ๐Ÿ”  Resolving packages...
Couldn't find any versions for "0" that matches "underscore"
? Please choose a version of "0" from this list: (Use arrow keys)

Which failed my CI and it seems it's because of the way dependencies are specified in this module (simple array, no versions).

For those of you, who might stumble on this problem, you can use a fork, such as this. Just do
yarn add https://github.com/BuildingConnected/node-google-places
And that should fix it up.
The downside is having a privately @ scoped dependency, so it's better to merge it in the main branch.

Confusing

places.search doesn't include a location object. lol, what is this library?

Reference field is deprecated

The reference field was deprecated on June 24 and replaced with place_id, so this module will stop working in about 9 months.

I'm happy to submit a pull request but I noticed there's an unmerged PR from June -- I wanted to see if you're still maintaining this module before I started work on it.

Thanks for putting together this module, Jay!

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.