Woosmap Loader

Load the Woosmap Store Locator JavaScript API script dynamically

  1. Loading the Woosmap loader.js file
  2. Loader Options
  3. Versioning

The Woosmap Loader is a small JS library used to load the Woosmap Store Locator JavaScript API script dynamically.


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

Loading the Woosmap loader.js file

Inline Loading


<script defer src="https://sdk.woosmap.com/locator/loader.js"></script>
<script>
    window.addEventListener("DOMContentLoaded", () => {
        // you can access WoosmapLoader here
    }, false);
</script>

Dynamic Loading

const loaderScript = document.createElement('script')
loaderScript.src = 'https://sdk.woosmap.com/locator/loader.js'
loaderScript.onload = () => {/* you can access WoosmapLoader here*/
}
document.head.append(loaderScript)

Loader Options

Once fully loaded to the DOM, the loader adds a global variable called WoosmapLoader. It helps you integrate the Woosmap Store Locator JS API with appropriate options (version, publicKey and callback to execute after script integration)

Call the WoosmapLoader.load(options) like below:


const woosmapLoadOptions = {
    version: "1.4", // 1.4 point currently to the latest available version
    publicKey: "woos-48c80350-88aa-333e-835a-07f4b658a9a4", //replace with your public key
    callback: initMap, //the callback to be executed once the API is fully loaded
    loadJQuery: false //JQuery is embedded by default but you can deactivate it
}

function initMap() {
    //the callback to be executed once the API is fully loaded
}

window.addEventListener("DOMContentLoaded", () => {
    WoosmapLoader.load(woosmapLoadOptions)
}, false);

Versioning

The Woosmap Store Locator JS API team regularly updates the API with new features, bug fixes, and performance improvements. The updates are listed in the release note.

You can indicate which version of the API to load in your application by specifying it in the Woosmap Loader parameter version.

We recommend loading the latest stable version: "1.4".

Was this article helpful?
Have more questions? Submit a request