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.
The project includes several examples of storelocatorjs
implementation in the directory examples
. Run the following commands to build the assets for the examples:
npm run build && npm run build:example
The library is available as the storelocatorjs
package name on npm.
npm install storelocatorjs --save-dev
yarn add storelocatorjs --dev
Online demo is available on https://storelocatorjs.github.io/demo.
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.
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>
Storelocatorjs contains many options to allow you to easily configure your map according to your needs. Options are available on the Storelocatorjs website.
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
});
})
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.
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.
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.
Created with β₯ by @yoriiis