Index: lib/src/google-map/google-map-search.html |
diff --git a/lib/src/google-map/google-map-search.html b/lib/src/google-map/google-map-search.html |
index 49d5a5ba1a91dac331c2596ae57c860962f01483..4554a348954209e1eba059a4dcbc7a46733a9ba8 100644 |
--- a/lib/src/google-map/google-map-search.html |
+++ b/lib/src/google-map/google-map-search.html |
@@ -11,8 +11,8 @@ information on the API. |
#### Example: |
<template is="dom-bind"> |
- <google-map-search map="[[map]]" libraries="places" query="Pizza" |
- results="{{results}}"></google-map-search> |
+ <google-map-search map="[[map]]" query="Pizza" results="{{results}}"> |
+ </google-map-search> |
<google-map map="{{map}}" latitude="37.779" |
longitude="-122.3892"> |
<template is="dom-repeat" items="{{results}}" as="marker"> |
@@ -119,7 +119,7 @@ information on the API. |
location: { |
type: Object, |
value: null, |
- readyOnly: true |
+ readOnly: true |
} |
}, |
@@ -129,13 +129,17 @@ information on the API. |
], |
/** |
+ * 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. |
* |
* @event google-map-search-results |
- * @param {Array} detail An array of search results |
- * @param {number} detail.latitude Latitude of the result. |
- * @param {number} detail.longitude Longitude of the result. |
- * @param {bool} detail.show Whether to show the result on the map. |
+ * @param {Array<{latitude: number, longitude: number}>} detail An array of search results |
*/ |
/** |
@@ -166,6 +170,26 @@ information on the API. |
} |
}, |
+ /** |
+ * 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 |