2.1.0 • Published 4 years ago

storelocatorjs v2.1.0

Weekly downloads
20
License
-
Repository
github
Last release
4 years ago

Storelocatorjs is a fast and lightweight Javascript library to easily build a store locator using Google Maps API V3. Only 6Kb on production with gzip, Storelocatorjs has no dependency with any framework or library and is written in Javascript native.

Installation

The library is available as the storelocatorjs package name on npm.

npm i --save-dev storelocatorjs
yarn add --dev storelocatorjs

Demo

Online demo is available on yoriiis.github.io/storelocatorjs/demo.html.

Storelocatorjs includes also several examples of storelocatorjs implementation.

How it works

Cloud functions

All requests to filter stores by geoposition are send to a cloud function as a web service. Storelocatorjs includes the cloud functions project from Google Firebase located in the ./functions folder.

Structure

The extended usage of the Storelocatorjs with filters and store categories used a minimalist HTML structure.

<div class="storelocator">
    <div class="storelocator-loader"></div>
    <div class="storelocator-sidebar">
        <form class="storelocator-formSearch" name="form-search">
            <input type="text" class="storelocator-inputSearch" placeholder="Enter a location" autocomplete="off" />
            <div class="storelocator-formFilters">
                <div class="storelocator-formFiltersRow">
                    <div class="storelocator-formCheckbox">
                        <input type="checkbox" id="cat-1" data-filter checked="checked" value="1" />
                        <label for="cat-1" class="category-1">Categorie 1</label>
                    </div>
                    <div class="storelocator-formCheckbox">
                        <input type="checkbox" id="cat-2" data-filter checked="checked" value="2" />
                        <label for="cat-2" class="category-2">Categorie 2</label>
                    </div>
                </div>
                <div class="storelocator-formFiltersRow">
                    <div class="storelocator-formCheckbox">
                        <input type="checkbox" id="cat-3" data-filter value="3" />
                        <label for="cat-3" class="category-3">Categorie 3</label>
                    </div>
                </div>
            </div>
        </form>
        <nav class="storelocator-nav">
            <ul class="storelocator-navList">
                <li class="storelocator-navListItem active">
                    <button class="storelocator-navButton" data-switch-view data-target="map">
                        Map
                    </button>
                </li>
                <li class="storelocator-navListItem">
                    <button class="storelocator-navButton" data-switch-view data-target="list">
                        List
                    </button>
                </li>
            </ul>
        </nav>
        <div class="storelocator-sidebarResults"></div>
    </div>
    <div class="storelocator-googleMaps active">
        <div id="storelocator-googleMapsCanvas"></div>
        <button class="storelocator-geolocButton"></button>
    </div>
</div>

Options

Storelocatorjs contains many options to allow you to easily configure your map according to your needs. Options are available on the Storelocatorjs website.

Example with the onReady function

The onReady function expose the Google Maps instance as map variable and is called when the map is instantiated and ready. With the example below, an automatic search is triggered with location coordinates passed in parameters.

new Storelocator({
    apiKey: '',
    webServiceUrl: ''
}, onReady: function(map) {
    this.triggerRequest({
        'lat': 48.8589507,
        'lng': 2.2770202
    });
})

Browsers support

The project is fully compatible with the most popular web browsers. More information about the Google Maps support on Google Developers. HTML and CSS files are W3C valid.

Licenses

Commercial license

If you want to use Storelocatorjs to develop commercial sites, themes, projects, and applications, the Commercial License is the appropriate license. With this option, your source code is kept proprietary. Purchase a Storelocatorjs Commercial License on the license page.

Open source license

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use Storelocatorjs under the terms of the GPLv3.

Contributors

Created with ♥ by @yoriiis. Many thanks to Cyril CAMBOURNAC for its contribution.