Giter Site home page Giter Site logo

simonneutert / jquery-google-reviews Goto Github PK

View Code? Open in Web Editor NEW
42.0 4.0 26.0 72 KB

simple jquery Plugin that utilizes Google API to get data from a Place on Google Maps

Home Page: https://github.com/simonneutert/jquery-google-reviews

License: ISC License

CSS 100.00%
jquery plugin jquery-plugin google-maps google-places-api reviews google-maps-api google stars

jquery-google-reviews's Introduction

jQuery Plugin to display Google Reviews of a Place on Google Maps

this will get the 5 reviews, google offers you.

But I need more than 5 reviews!

if you need more, let me direct you a bit: https://developers.google.com/my-business/content/review-data#list_all_reviews - but this will be a different project all by its own

I do not like jQuery!!!1eleven

The NPM Package is here - Frontend Devs will know how to webpack :) or simply extract the code and adapt it to your needs, dropping jQuery as a dependency.

Credits

Inspired by Steven Monson's magnificent article here: https://www.launch2success.com/guide/display-google-reviews-website-2017/ or check out Steven's github. Steven's code is based on peledies jquery plugin repo. So, I simply remixed their work into this repo. Thank you guys!

Dear beginners and copy-pasters

:octocat: For those of you, who are new in programming or can only copy-paste, please make sure, that jQuery, the Google Maps API and the .js-file of this plugin are successfully loaded, before you call this script in your html page.

./demo/index.html is a working demo, the comments will guide you 😉

Prerequisites

  • You must have jQuery in your project: jQuery

  • add the .js and .css of this repo to your project (see ./demo/index.html for inspiration 😉)

  • if you do not have a working Google Maps API key already: create a Google API Key: https://console.developers.google.com/apis/ make sure to set a limit to your payments

  • add the following line with your Google Maps API key with the key param:

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=YourApiKeyHere"></script>
  • add an empty div element in your html template with an unique ID, where the reviews should show up. In this case:

    <div id="google-reviews"></div>

How to get link to “View All Google Reviews” or "Write a review"

Please see the official Documents for this topic:
https://developers.google.com/my-business/content/review-data#list_all_reviews

  • Step 1. Open a browser, but don’t use Chrome. You can use Firefox, or Edge, or even Internet Explorer but not Google Chrome because it alters the URL and your link will not work correctly.

  • Step 2. Go to Google.com and search for your company’s name.

  • Step 3. Find the card on the right and click “View All Google Reviews” or "Write a review"

  • Step 4. Copy the URL in the address bar.

  • Step 5. Now paste the URL as a link on more_reviews_button_url or write_review_button_url param.

Call the Plugin

Grab your place's ID (https://developers.google.com/places/place-id) and call it as placeId parameter, when calling the plugin.

<script>
jQuery(document).ready(function($) {
  if ($("#google-reviews").length == 0) {
    return
  }
  // Find a placeID via https://developers.google.com/places/place-id
  $("#google-reviews").googlePlaces({
    placeId: 'ChIJZa6ezJa8j4AR1p1nTSaRtuQ',
    // the following params are optional (default values)
    header: "<h3>Google Reviews</h3>", // html/text over Reviews
    footer: '', // html/text under Reviews block
    maxRows: 5, // max 5 rows of reviews to be displayed
    minRating: 4, // minimum rating of reviews to be displayed
    months: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
    textBreakLength: "90", // length before a review box is set to max width
    shortenNames: true, // example: "Max Mustermann" -> "Max M."",
    moreReviewsButtonUrl: '', // url to Google Place reviews popup
    moreReviewsButtonLabel: 'Show More Reviews',
    writeReviewButtonUrl: '', // url to Google Place write review popup
    writeReviewButtonLabel: 'Write New Review',
    showProfilePicture: true
  });
});
</script>

Are Pull Requests welcome?

Yes, of course :octocat:

You do not need to update the demo folder! I will do this, when your code was merged.

jquery-google-reviews's People

Contributors

dziduszka avatar ottopic avatar simonneutert 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

Watchers

 avatar  avatar  avatar  avatar

jquery-google-reviews's Issues

Google Reviews Error

Uncaught TypeError: Cannot read property 'open_now' of undefined
at callback (jquery-google-reviews.js:113)
at places_impl.js:17
at places_impl.js:15
at util.js:208
at common.js:54
at Zl.f (common.js:15)
at Ml.j (common.js:54)
at Object.c [as _rgg3c0] (common.js:48)
at PlaceService.GetPlaceDetails?2sen-US&8sChIJHduuXU1VwokRBtBklimBjmQ&10e3&17m1&2e1&key=AIzaSyCJP67JWpe96_DILfz-_QpN3Gf_DltGqlI&callback=xdc._rgg3c0&token=122370:1

Not working

Hello,

i downloaded the project and applied an api key from Google Places API. Also, i inserted a place id, but when i opened the index.html file, nothing was apperared in my browser. Is there something else that i can do?

How to call new comments?

I've been using this plugin and it works great. But the problem is it does not fetch latest comments. I've tried to call the reviews again and and even from a different project but still the same selected reviews are the only ones that plugin fetches. So how to call new comments?

API not authorized

Hi, i've got an issue with the API.
When i just activated it it works without any problem, but after a few minutes i get an error "This API project is not authorized to use this API. Please ensure this API is activated in the Google Developers Console[...]" ...
If i desactivate and reactivate the API it works again for a few minutes.

Any ideas ?

Latest Reviews

Hi There!

Awesome work putting up a basic request and html setup! But i noticed one thing when i try to use it in my project. The data you get in the response is the top 5 most relevant reviews instead of latest reviews. Is there a way to tell the API to get the latest review instead of most relevant reviews?

Cheers

Uncaught TypeError: Cannot read property 'length' of undefined

Uncaught TypeError: Cannot read property 'length' of undefined
at filterReviewsByMinRating (jquery-google-reviews.js:76)
at callback (jquery-google-reviews.js:115)
at places_impl.js:17
at places_impl.js:15
at util.js:208
at common.js:54
at Zl.f (common.js:15)
at Ml.j (common.js:54)
at Object.c [as _rgg3c0] (common.js:48)
at PlaceService.GetPlaceDetails?2sen-US&8sChIJHduuXU1VwokRBtBklimBjmQ&10e3&17m1&2e1&key=AIzaSyCJP67JWpe96_DILfz-_QpN3Gf_DltGqlI&callback=xdc._rgg3c0&token=99670:1

Truncate reviews text?

Hello,

First of all I'm not a JS tech guy, more HTML/CSS.

Any option to truncate the reviews text depending of the number of words/letters instead of "textBreakLength"? And a an ellipsis or a custom text like "Read more..."?

Thanks, have a nice day.

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.