Skip to content

Commit

Permalink
Merge pull request #208 from GoogleWebComponents/details
Browse files Browse the repository at this point in the history
Add details place fetch
  • Loading branch information
ebidel committed Sep 25, 2015
2 parents c49e4f3 + 51aaa36 commit 1468409
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion google-map-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2>{{marker.name}}</h2>
location: {
type: Object,
value: null,
readyOnly: true
readOnly: true
}
},

Expand All @@ -128,6 +128,13 @@ <h2>{{marker.name}}</h2>
'_updateLocation(latitude,longitude)'
],

/**
* Fired when the details of a place are returned.
*
* @event google-map-search-place-detail
* @param {google.maps.MarkerPlace} detail The place details.
*/

/**
* Fired when the search element returns a result.
*
Expand Down Expand Up @@ -166,6 +173,26 @@ <h2>{{marker.name}}</h2>
}
},

/**
* Fetches details for a given place.
* @param {String} placeId The place id.
* @return {Promise} place The place information.
*/
getDetails: function(placeId) {
var places = new google.maps.places.PlacesService(this.map);

return new Promise(function(resolve, reject) {
places.getDetails({placeId: placeId}, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
resolve(place);
this.fire('google-map-search-place-detail', place);
} else {
reject(status);
}
}.bind(this));
}.bind(this));
},

_gotResults: function(results, status) {
this.results = results.map(function(result) {
// obtain lat/long from geometry
Expand Down

0 comments on commit 1468409

Please sign in to comment.