Git Product home page Git Product logo

google-places's Introduction

google-places

A jQuery plugin to render google places data.

Currently the only only thing that is rendered is a list view of reviews.

Demos

Install

Install with bower.

bower install google-places

Install with npm

npm install google-places-data

Include

Include these files in the head

<link rel="stylesheet" href="bower_components/google-places/google-places.css">
<script src="bower_components/google-places/google-places.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>

Options

Required Description
placeId google placeId
Optional Type Description Default
render Array supports reviews, schema, phone, address, hours, staticMap ['reviews','phone','hours','address,'staticMap']
min_rating Int Only display reviews with a minimum rating (not applicable for schema) 0
max_rows Int Maximum number of rows to show - 0 for all (not applicable for schema) 0
map_plug_id String ID to use for 'map-plug' map-plug
rotateTime Int Time in MS to show review before rotating or false for no rotate false
shorten_names Int Shorten Author Last Name to X. true
schema Object Options for displaying Schema see below

Optional Schema Markup

The schema markup will render something like below:

<span itemscope="" itemtype="http://schema.org/Hostel">
  <meta itemprop="image" content="https://via.placeholder.com/150">
  <meta itemprop="priceRange" content="$$">
  <meta itemprop="url" content="https://example.org">
  <meta itemprop="telephone" content="(303) 954-0962">
  <div itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress" style="display: none;">
    <span class="street-address" itemprop="streetAddress">1217 20th St</span>,
    <span class="locality" itemprop="addressLocality">Denver</span>,
    <span class="region" itemprop="addressRegion">CO</span>
    <span class="postal-code" itemprop="postalCode">80202</span>,
    <span class="country-name" itemprop="addressCountry">USA</span>
  </div>
  Google Users Have Rated
  <span itemprop="name">Hostel Fish</span>
  <span itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue">4.80</span>/<span itemprop="bestRating">5</span>
    based on <span itemprop="ratingCount">5</span>
    ratings and reviews
  </span>
</span>
Schema Type Description Default
displayElement Object Jquery object or string location where the schema will be appended '#schema'
beforeText String Text before ratings 'Google Users Have Rated'
middleText String Text in between ratings 'based on'
afterText String last text in rating 'ratings and reviews'
type String schema.org type 'Store'
image String url to your company image null
priceRange String Price range ($$) null

staticMap options

property Description Default
width map width 512
height map height 512
zoom zoom index for map 17
type map type (roadmap, terrain, satellite, hybrid) roadmap

Usage

$("#google-reviews").googlePlaces({
    placeId: 'ChIJa2uI-Nt4bIcR5cvnOxD4cFg'
  , render: ['reviews']
  , min_rating: 4
  , max_rows:5
  , map_plug_id: 'map-plug'
  , rotateTime:5000
  , shorten_names: true
  , schema: {
            displayElement: '#schema' // optional, will use "#schema" by default
          , beforeText: 'Googlers rated'
          , middleText: 'based on'
          , afterText: 'awesome reviewers.'
          , type: 'Hostel'
          , image: 'https://via.placeholder.com/150'
          , priceRange: '$$'
      }
  , address:{
    displayElement: "#custom-address-id" // optional, will use "#google-address" by default
  }
  , phone:{
    displayElement: "#custom-phone-id" // optional, will use "#google-phone" by default
  }
  , staticMap:{
      displayElement: "#google-static-map" // optional, will use "#google-static-map" by default
  }
  , hours:{
      displayElement: "#google-hours" // optional, will use "#google-hours" by default
  }
});

Events

The plugin will trigger the following events, namespaced to 'googlePlaces'

Event Target Description
beforeRender element plugin Triggered just before 'display elements' any are rendered
afterRender element plugin Triggered just after all 'display elements' are rendered
function sayHi() {
    alert('Hi!');
}

$("#google-reviews").on('afterRender.googlePlaces', sayHi);

google-places's People

Contributors

bpedroza avatar chedaroo avatar dfmn avatar peledies avatar rakibabu avatar sfp-deac avatar weilinzung 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  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  avatar  avatar  avatar

google-places's Issues

No reviews anymore

Best, since a few days reviews are not displaying anymore and i am not getting an error or console feedback. Any idea on how to solve this issue? Thank you

google is not defined

Using the basic markup (supplied) I am seeing this error -
Uncaught ReferenceError:
google is not defined
initialize_place @ google-places.js:32
plugin.init @ google-places.js:22
$.googlePlaces @ google-places.js:108
(anonymous function) @ google-places.js:116
n.extend.each @ jquery-2.1.4.min.js:2
n.fn.n.each @ jquery-2.1.4.min.js:2
$.fn.googlePlaces @ google-places.js:114
(anonymous function) @ index.html:320

Username not showing

reviews[i].author_name is no longer outputting username, instead of usernames all reviews show they are from "A Google User"

Not Updating

I put the the code from the usage section is a function and replaced the placeid with a variable.

Im using this in conjunction with leaflet.js and have it setup so that when a marker on the map is clicked, the following is run :

The place id is stored in the description field.

var locaionID = layer.feature.properties.description;
                getInfo(locaionID );

Then in the function I have where the example placeID was String(locationID),

The problem is that the function will only run once, which is a bit of a problem if there are multiple locations.

I have checked and the location ID of each location is being passed into the function, but it just doesn't update after its first been called.

How to get more than 5 reviews

Hello, thanks for this package. I see that the number of reviews am getting from google is limited to 5. How can I get all the reviews?

Display more than 5 reviews

Hi, first of all thanks for the great project. Is it possible to see more than 5 reviews? That would be very cool.

Trunc review length?

Hi,

Is there a way to truncate the number of characters of a review?

Thanks,

Maurice

API Key

Does this plugin require an API key from google places ?

licence ?

i want to use your plugin for a project - what are the licence terms ?

Cannot read property 'sort' of undefined

I have set everything up as instructed, however, am now receiving the following error in the console...

Uncaught TypeError: Cannot read property 'sort' of undefined
at sort_by_date (google-places.js:141)
at renderReviews (google-places.js:177)
at google-places.js:65
at google-places.js:135
at places_impl.js:46
at places_impl.js:44
at Mp.e [as o] (places_impl.js:27)
at Object.c [as _c3k8wv] (common.js:67)
at PlaceService.GetPlaceDetails?2sen-US&10e3&14m1&1sChIJwVvhYVOSekgRYxdRMwRV_UU&17m1&2e1&callback=xdc._c3k8wv&key=AIzaSyB4sUcbLV4bRem7xI6gt-u_qQkRtsbIcRA&token=98149:1

I'm at a loss of what to do here. I followed something suggested in another issue posted here, by adding a billing account to my google cloud platform but it still hasn't resolved the error. Any suggestions?

Schema Markup

Schema Markup is rendering perfectly but the star rating dose not showing in google search result. Is there any way to fix it?

Does not returns recent

Hi,

Thanks for your plugin.

I have configured the plugin according to your documentation. It returns the reviews. But the problem is, returned reviews are not most recent ones. Also it doesn't give reviews more than 5.

Could you please guide me ?

Doesn't fetch last reviews ...

Hi.

I've set up all the params and it is working fine, but it's been a week it does not show the newest reviews...
Eg: I had 2 reviews since 04 Sept 2016 but the last one the plugins displays is 31 Aug 2016 ...

(yes I deleted my browser cache :))

Thanks for your input :)

How do I enable the other data?

So, the other Places Details data is there (I can see it in debugger), but the script doesn't grab it due to: if(element instanceof jQuery){ ... }

What's going on here?

Order reviews

Does Someone know why the five reviews returned are not the last five more recent?

Best regards.

Overall average rating

Thanks for the great script!

I have a couple of quick issues.

Is there a way to render the place's average rating?

Only the most recent 5 reviews are being rendered, 2 years and newer. We have a 5* review, 3 years old that is being missed off.

Any pointers greatly received!

why show only 5 review?

Hi, first of all thanks for your script!
I did some tests but it only ever shows me 5 reviews (even if there are 100), is there a way to read more?

Uncaught TypeError: Cannot read property 'sort' of undefined

Reviews stopped showing recently, here is the error:

Uncaught TypeError: Cannot read property 'sort' of undefined
at sort_by_date (google-places.js:53)
at renderReviews (google-places.js:74)
at google-places.js:28
at google-places.js:47
at places_impl.js:19
at places_impl.js:17
at places_impl.js:9
at common.js:54
at common.js:15
at common.js:54

Uncaught TypeError: $(...).googlePlaces is not a function

I get this error even though I am certain my code doesn't have any errors. This happened a few times over the last few days when I was trying to make the call every few seconds for a different place but it didn't work.

Today, I tried this on another page on my app and I get the same error.

<script> $(".total-rating").googlePlaces({ placeId:'ChIJLacTRpnP5zsRtOJpe7NrSg8', render: ['rating','user_ratings_total'], min_rating: 5, max_rows: 5 }); </script>
The above lines are the code I tried today.

Since I got this error in a simple config as well, I decided to open an issue hoping my code not working was an issue here.

var place_ids = ['ChIJLcfHA5TR5zsRmOq0N5PTlLQ','ChIJSwJZDee35zsRfuNRzpQFYeA', 'ChIJGSc5XXLJ5zsRbDgy1RkzwzY'] i = -1; (function f(){ i = (i + 1) % place_ids.length; $('.currentPlaceId').text(place_ids[i]); $(".custom-google-reviews").googlePlaces({ placeId: $('.currentPlaceId').text(), //Find placeID @: https://developers.google.com/places/place-id render: ['reviews'], min_rating: 5, max_rows: 5 }); $(".total-rating").googlePlaces({ placeId: $('.currentPlaceId').text(), //Find placeID @: https://developers.google.com/places/place-id render: ['rating','user_ratings_total'], min_rating: 5, max_rows: 5 }); setTimeout(f, 5000); })();

The above code is what I tried to use when I wanted to get reviews for multiple places but only one at a time but even this didn't work. I know it isn't the best approach and updating the DOM is another issue with this approach but the first piece of code not working is not helping either.

not workin

The demo page is not working. I was wondering if this code is still working?

Thanks

Does not show recent reviews

i have 3 reviews and doesnt return the latest, if i put 4 i see one more recent than if i put three, how can i change the order or display the most recent ones?

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.