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/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>
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'

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'
      }
  , 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

peledies avatar bpedroza avatar chedaroo avatar sfp-deac avatar weilinzung avatar rakibabu avatar dfmn avatar

Stargazers

MD Hasan Patwary avatar

Watchers

James Cloos avatar Saiful Islam avatar

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.