Fallback Search: Woosmap Localities then Google Places or Woosmap Address

Woosmap Localities API is a web service that returns geographical places like city names, postal codes, suburbs,… commonly used for autocompletion feature to suggest predictions as the user types.

Even if this API can satisfy most of your user’s searches, in some cases, it do not return the appropriate suggestions.

To give you the best chance to make a winning first impression, you could trigger the call to another autocomplete API like Google Places or Woosmap Address API.

The key point is to decide “when” do this fallback search.

We’ve built a small library/widget called Localities Fallback which computes a matching ratio between the user input and for each returned localities items. If Woosmap Localities return no item with a matching Ratio = 100 (customizable using breakpointRatio parameter), the widget populates the predictions pick list with Google Places or Woosmap Address items.

The ratio value is added to each autocomplete item and calculated as a partial levenshtein ratio of the two strings: the input from the user and the description of autocomplete item. We use a fuzzy searching algorithm.

Example with fallback search on Google Places:


You can see a fallback search on Woosmap Address here

The source code of this widget is available on GitHub.