Localities Javascript API

Search for city names and postcodes
  1. Introduction
  2. Sample Usage

Introduction

The Localities Javascript API enable your users to search for city names and postcodes. It’s a lightweight JavaScript library to quickly implement Localities REST API.

Add the following snippet to the <head> tag of your site.

<script src="https://sdk.woosmap.com/localities/localities.js"></script>

To begin with the Localities Service, you need to build a new AutocompleteService object passing the key parameter corresponding to your project public key.

const key = 'woos-xxxx'; //your project public key
let autocompleteService = new woosmap.localities.AutocompleteService(key);

Sample Usage

Here is a simple sample to help you using the Localities JS API.

On each keyup event fired on the dedicated text input, a getQueryPredictions() is called and results displayed below.

To understand how to go deeper with the Localities JS API, please check the Localities JS API Reference.