erdem / django-map-widgets

Highly customizable, intuitive, and user-friendly map widgets for GeoDjango applications.
MIT License
449 stars 119 forks source link

Add delay for autocomplete #107

Closed cddumanov closed 4 years ago

cddumanov commented 4 years ago

I don't like that autocomplete throws a ton of requests during typing. For example I'm looking for Mysuper City valley street. When I start typing My it already sends 2+ requests and shows results that I don't need. How to make 3 second delay like show result only after 3 seconds when user released the last key? Thanks a lot!

erdem commented 4 years ago

Hi @cddumanov

I didn't like this functionality problem as well. I tried to implement this functionality when I was developing this project. I couldn't implement typing events delays because google map JS library wasn't binding events to custom handlers.

https://issuetracker.google.com/issues/35823678

It seems Google didn't fix this on JS API side yet. As far as I read the topic, there are some workaround ways but not sure they work in all browsers etc.

I am happy to merge your PR if you solve this problem.

https://github.com/erdem/django-map-widgets/blob/master/mapwidgets/static/mapwidgets/js/django_mw_base.js#L19

You can find related event handlers in this file.

Thanks