Getting started
Installation¶
NPM¶
Install Storelocatorjs with npm:
1 |
|
1 2 3 4 5 6 7 |
|
Manual import¶
Includes files manually in your project:
1 2 3 4 5 6 7 8 9 |
|
Load Google Maps API¶
Google Maps API is automatically loaded by storelocatorjs. The map is instanciate when the API is ready.
API key¶
Create an API key to use Google Maps API on the Google Console API.
Cloud function¶
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.
Storelocatorjs examples are linked to the cloud function. To run locally the cloud function, simply create a .env
from the .env.dist
file in the ./functions
directory and fill the CLOUD_FUNCTION_DOMAIN
variable with you virtual host to authorize CORS requests.
Then, to run Storelocatorjs examples, simply run the following commands:
1 2 3 |
|
Cloud function will be automatically accessible locally on Storelocatorjs examples in the ./examples
folder.
JSON structure¶
The storelocatorjs project includes a JSON example in the folder ./functions/database.json
.
Datas are stored in an array of object for better performance.
Mandatory JSON structure
It is important to respect the format of the keys in the JSON file.
In case of filters usage, the category value in the highlight line must correspond to the filter value
attributes in the HTML.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 |
|
JSON fields¶
List of available fields in the JSON. Mandatory fields are lat
and lng
.
lat
¶
mandatory - float
The latitude of the store.
1 2 3 4 5 |
|
lng
¶
mandatory - string
The longitude of the store.
1 2 3 4 5 |
|
address
¶
string
The address of the store.
1 2 3 4 5 |
|
category
¶
string
The category of the store.
1 2 3 4 5 |
|
city
¶
string
The city of the store.
1 2 3 4 5 |
|
id
¶
integer
The id of the store.
1 2 3 4 5 |
|
phone
¶
string
The phone of the store.
1 2 3 4 5 |
|
title
¶
string
The title of the store.
1 2 3 4 5 |
|
zipcode
¶
string
The zipcode of the store.
1 2 3 4 5 |
|