Skip to content

Commit

Permalink
Release version 0.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed May 25, 2020
1 parent 697808d commit 473222e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
11 changes: 9 additions & 2 deletions dist/mapbox-gl-indoorequal.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ const layers = [
* @param {object} map the mapbox-gl instance of the map
* @param {object} options
* @param {url} [options.url] Override the default tiles URL (https://tiles.indoorequal.org/).
* @param {string} [options.apiKey] The API key if you use the default tile URL (get your free key at [indoorequal.com](https://indoorequal.com)).
* @property {string} level The current level displayed
* @property {array} levels The levels that can be displayed in the current view
* @fires IndoorEqual#levelschange
Expand All @@ -293,9 +294,14 @@ const layers = [
*/
class IndoorEqual {
constructor(map, options = {}) {
const opts = { url: 'https://tiles.indoorequal.org/', ...options };
const defaultOpts = { url: 'https://tiles.indoorequal.org/' };
const opts = { ...defaultOpts, ...options };
if (opts.url === defaultOpts.url && !opts.apiKey) {
throw 'You must register your apiKey at https://indoorequal.com before and set it as apiKey param.';
}
this.map = map;
this.url = opts.url;
this.apiKey = opts.apiKey;
this.levels = [];
this.level = "0";
this.events = {};
Expand Down Expand Up @@ -361,9 +367,10 @@ class IndoorEqual {
}

_addSource() {
const queryParams = this.apiKey ? `?key=${this.apiKey}` : '';
this.map.addSource(SOURCE_ID, {
type: 'vector',
url: this.url
url: `${this.url}${queryParams}`
});
layers.forEach((layer) => {
this.map.addLayer({
Expand Down
11 changes: 9 additions & 2 deletions dist/mapbox-gl-indoorequal.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ const layers = [
* @param {object} map the mapbox-gl instance of the map
* @param {object} options
* @param {url} [options.url] Override the default tiles URL (https://tiles.indoorequal.org/).
* @param {string} [options.apiKey] The API key if you use the default tile URL (get your free key at [indoorequal.com](https://indoorequal.com)).
* @property {string} level The current level displayed
* @property {array} levels The levels that can be displayed in the current view
* @fires IndoorEqual#levelschange
Expand All @@ -289,9 +290,14 @@ const layers = [
*/
class IndoorEqual {
constructor(map, options = {}) {
const opts = { url: 'https://tiles.indoorequal.org/', ...options };
const defaultOpts = { url: 'https://tiles.indoorequal.org/' };
const opts = { ...defaultOpts, ...options };
if (opts.url === defaultOpts.url && !opts.apiKey) {
throw 'You must register your apiKey at https://indoorequal.com before and set it as apiKey param.';
}
this.map = map;
this.url = opts.url;
this.apiKey = opts.apiKey;
this.levels = [];
this.level = "0";
this.events = {};
Expand Down Expand Up @@ -357,9 +363,10 @@ class IndoorEqual {
}

_addSource() {
const queryParams = this.apiKey ? `?key=${this.apiKey}` : '';
this.map.addSource(SOURCE_ID, {
type: 'vector',
url: this.url
url: `${this.url}${queryParams}`
});
layers.forEach((layer) => {
this.map.addLayer({
Expand Down
2 changes: 1 addition & 1 deletion dist/mapbox-gl-indoorequal.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mapbox-gl-indoorequal",
"version": "0.0.7",
"version": "0.1.0",
"description": "Integrate indoor= into your mapbox-gl.js map.",
"repository": "https://github.com/indoorequal/mapbox-gl-indoorequal",
"author": "François de Metz",
Expand Down

0 comments on commit 473222e

Please sign in to comment.