google-map icon indicating copy to clipboard operation
google-map copied to clipboard

Added the `loading` property to `google-map-search`.

Open tekkamanendless opened this issue 9 years ago • 0 comments

I try to minimize the amount of Javascript that my elements need to function, and the lack of a loading property on google-map-search forced me to do a lot more event handling than I would have liked. So, I added one.

Essentially, loading defaults to false. It is set to true in the search method, and it is set to false once again in the _gotResults method. It is updated before google-map-search-results is fired, so that event will properly occur once all search actions are complete.

I also added a unit test around searching. I noticed that most of the tests won't run properly without an api-key set on the google-map, so I guess that we'll all just have to insert our own during testing? Kinda strange.

Anyway, this will now let you easily notify your users that a search is in progress. Previously, this had to be done with a lot more hooks and events.

<google-map-search map="[[map]]" results="{{results}}" loading="{{loading}}"></google-map-search>

<template is="dom-if" if="[[loading]]">
  Loading...
</template>
<template is="dom-if" if="[[!loading]]">
  <ul>
  <template is="dom-repeat" items="[[results]]">
    <li>[[item.formatted_address]]</li>
  </template>
  </ul>
</template>

tekkamanendless avatar Jun 19 '17 02:06 tekkamanendless