0.1.1 • Published 7 years ago

google-places-data v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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

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

RequiredDescription
placeIdgoogle placeId
OptionalTypeDescriptionDefault
renderArraysupports reviews, schema, phone, address, hours, staticMap'reviews','phone','hours','address,'staticMap'
min_ratingIntOnly display reviews with a minimum rating (not applicable for schema)0
max_rowsIntMaximum number of rows to show - 0 for all (not applicable for schema)0
rotateTimeIntTime in MS to show review before rotating or false for no rotatefalse
schemaObjectOptions for displaying Schemasee below

Optional Schema Markup

The schema markup will render something like below:

<span itemscope="" itemtype="http://schema.org/Store">
    <meta itemprop="url" content="http://example.com">
    Google Users Have Rated 
    <span itemprop="name">
        Hostel Fish
    </span> 
    <span itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating">
        <span itemprop="ratingValue">5</span>/<span itemprop="bestRating">5</span> 
        based on <span itemprop="ratingCount">5</span> ratings and reviews
    </span>
</span>
SchemaTypeDescriptionDefault
displayElementObjectJquery object or string location where the schema will be appended'#schema'
beforeTextStringText before ratings'Google Users Have Rated'
middleTextStringText in between ratings'based on'
afterTextStringlast text in rating'ratings and reviews'
typeStringschema.org type'Store'

staticMap options

propertyDescriptionDefault
widthmap width512
heightmap height512
zoomzoom index for map17
typemap type (roadmap, terrain, satellite, hybrid)roadmap

Usage

$("#google-reviews").googlePlaces({
    placeId: 'ChIJa2uI-Nt4bIcR5cvnOxD4cFg'
  , render: ['reviews']
  , min_rating: 4
  , max_rows:5
  , rotateTime:5000
  , schema: {
            displayElement: '#schema' // optional, will use "#schema" by default
          , beforeText: 'Googlers rated'
          , middleText: 'based on'
          , afterText: 'awesome reviewers.'
          , type: 'Hostel'
      }
  , 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
  }
});