Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion google-map-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,39 @@ <h2>{{marker.name}}</h2>
},

/**
* Warning: The implementation for types in text search requests is changing. The types parameter is deprecated
* as of February 16, 2016, replaced by a new type parameter which only supports one type per search request.
* Additionally, the establishment, place_of_worship, food, health, general_contractor and finance types will
* no longer be supported as search parameters (however these types may still be returned in the results of a
* search). Requests using the deprecated features will be supported until February 16, 2017, after which all
* text searches must use the new implementation.
* See https://developers.google.com/maps/documentation/javascript/places
*
* Space-separated list of result types.
* The search will only return results of the listed types.
* See https://developers.google.com/places/documentation/supported_types
* for a list of supported types.
* Leave empty or null to search for all result types.
*
* @deprecated
*/
types: {
type: String,
value: null
},

/**
* Search result type
* The search will only return results of the listed type.
* See https://developers.google.com/places/documentation/supported_types
* for a list of supported types.
* Leave empty or null to search for all result types.
*/
type: {
type: String,
value: null
},

/**
* The search results.
*/
Expand Down Expand Up @@ -147,13 +169,18 @@ <h2>{{marker.name}}</h2>
* Perform a search using for `query` for the search term.
*/
search: function() {
if (this.query && this.map) {
if (this.map && (this.query || this.type)) {
var places = new google.maps.places.PlacesService(this.map);

if (this.types && typeof this.types == 'string') {
var types = this.types.split(' ');
}

if (this.type && typeof this.type == 'string') {
var typeArray = this.type.split(' ');
var type = typeArray[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to init type outside this conditional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something, but is there a reason why type needs to be initialized outside a conditional more than any of the others here? Do you want me to init all of them at the top?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that the precedence has already been set :) I guess places.textSearch is cool with undefined values for keys?

}

if (!this.globalSearch) {
var bounds = this.map.getBounds();
} else if (this.radius) {
Expand All @@ -164,6 +191,7 @@ <h2>{{marker.name}}</h2>
places.textSearch({
query: this.query,
types: types,
type: type,
bounds: bounds,
radius: radius,
location: location
Expand Down