Friday, March 18, 2016

Developers: Saving Google API Credits with Autocomplete

There are a lot of winners with Google's new API pricing. However, if your app is using the whole suite of mapping functionality and you have a lot of users you might find your pool will start declining fast. Two functions that will draw directly on your pool and are not subject to the daily free quota is autocomplete and place search.

If you use your Google licence with the Scribble Maps API we do some of these optimizations out of the box, but if you are building your own custom implementation directly on top of the Google Maps API, there is a simple update you can do to save you some autocomplete credits.

The standard auto-complete functionality will send out an auto-complete request with every change in the input. It's possible to cut the amount of credits used significantly by putting in a timeout when the input changes.

Here is a very basic example.

 var acTimeOut;  
 textSearchInput.onkeyup = function() {  
 clearTimeout(acTimeout);  
 acTimeout = setTimeout(function() {  
 //put auto-complete calls in here  
 }, 250);  
 }  

So every time a user starts typing in the input the autocomplete will not fire until there is a momentary delay. The delay of 250ms can be reduced to make the autocomplete fire more often. If the user quickly types "Toronto", only one auto-complete call will be executed instead of 8 when the user hesitates.

We find the timed delay works the best. A critical point to this is to make sure that the user interface indicates that a search is going on as they are typing. In our case we use an animated spinner. This way if the user is typing quickly and not seeing results, the animated spinner will give them enough pause to see the results.

It should be noted that implementing this is compliant with their current terms of use. All this method essentially does is throttle the amount of out bound autocomplete calls from the user.

13 comments:

  1. I have never known Scribble Map up until now. I only use Google Map. This is great! We would have an alternative way in finding places.

    ReplyDelete
  2. At any rate the publicists began griping to Google that their publicizing cash was being squandered, Google listened and changed a tad bit progressively and adequately hindered the Adsense moonlight trip to a dead end. It was about this time the Adsense euphoria riders (Adsense sneakmeisters) started offering their products...and offering them hard! https://800support.net/sign-up/gmail-sign-up-gmail-register/

    ReplyDelete
  3. Thanks for discussing this issue. API credits can really be helpful in boosting business page for essay writing services online, so better know how to integrate it properly.

    ReplyDelete
  4. در دنیای امروز آژانس هواپیمایی که می توان با آژانس مسافرتی با همین شکل که می توان ببیط ماهان به همین روش که وجود تور ارزان در اواسط سال جدید تور مسافرتی در اواسط سال جدید هواپیمایی قطر که یکی از بهترین آژانس در این کار هواپیمایی امارات هم همین طور.

    ReplyDelete
  5. در دنیای امروز بلیط هواپیما که در روزهای هواپیما به همین شکل از الی گشت و آژانس های توری با بلیط هواپیما لحظه آخری و هر کدام از آژانس مسافرتی مارکوپولو که یکی از واحد های آژانس ققنوس از آخرین آژانس های آژانس مسافرتی ققنوس که در سالهای اخیر آژانس هواپیمایی تهران در یکی از آژانس ها باشد.

    ReplyDelete
  6. امروزه یکی از رزرو بلیط هواپیما که سخت هم نیست به همین شکل از قیمت بلیط هواپیما و رزرو آن هم آژانس مسافرتی مشهد در روزهای اخیر آژانس مسافرتی اصفهان که یکی از مهمترین اوج سفر و یکی دیگر از اوج سفر ایرانیان در روزهای اخیر آژانس اوج سفر که هر یک از آژانس مسافرتی اوج سفر و در هر وقت که آژانس هواپیمایی اوج سفر و هر حالتی که باشد.

    ReplyDelete
  7. Learn Some tips to recover gmail password :- http://www.customercare-email.com/forgot-gmail-password.html

    ReplyDelete
  8. Do you know what is best way to prevent POP3 and IMAP configuration problems, if your answer is no then contact Yahoo support phone number anytime.

    ReplyDelete