Skip to content

Commit

Permalink
Release version 0.0.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed Sep 26, 2021
1 parent 3c2a7c8 commit 0475bb5
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 10 deletions.
125 changes: 117 additions & 8 deletions dist/mapbox-gl-indoorequal.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ var proj_js = require('ol/proj.js');
var TileGrid = require('ol/tilegrid/TileGrid.js');
var control = require('ol/control');
var BaseObject = require('ol/Object');
var Style = require('ol/style/Style');
var Fill = require('ol/style/Fill.js');
var Stroke = require('ol/style/Stroke');
var Text = require('ol/style/Text');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

Expand All @@ -19,6 +23,10 @@ var TileJSON__default = /*#__PURE__*/_interopDefaultLegacy(TileJSON);
var MVT__default = /*#__PURE__*/_interopDefaultLegacy(MVT);
var TileGrid__default = /*#__PURE__*/_interopDefaultLegacy(TileGrid);
var BaseObject__default = /*#__PURE__*/_interopDefaultLegacy(BaseObject);
var Style__default = /*#__PURE__*/_interopDefaultLegacy(Style);
var Fill__default = /*#__PURE__*/_interopDefaultLegacy(Fill);
var Stroke__default = /*#__PURE__*/_interopDefaultLegacy(Stroke);
var Text__default = /*#__PURE__*/_interopDefaultLegacy(Text);

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
Expand Down Expand Up @@ -150,6 +158,8 @@ function _assertThisInitialized(self) {
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

return _assertThisInitialized(self);
Expand Down Expand Up @@ -201,10 +211,10 @@ function onTileJSONLoaded(layer, tilejson) {
var extent = extentFromTileJSON(tileJSONDoc);
var minZoom = tileJSONDoc.minzoom;
var maxZoom = tileJSONDoc.maxzoom;
var source = new VectorTileSource__default['default']({
var source = new VectorTileSource__default["default"]({
attributions: tilejson.getAttributions(),
format: new MVT__default['default'](),
tileGrid: new TileGrid__default['default']({
format: new MVT__default["default"](),
tileGrid: new TileGrid__default["default"]({
origin: tileGrid.getOrigin(0),
extent: extent || tileGrid.getExtent(),
minZoom: minZoom,
Expand All @@ -218,11 +228,11 @@ function onTileJSONLoaded(layer, tilejson) {
}

function getLayer(url, options) {
var layer = new VectorTileLayer__default['default'](_objectSpread2({
var layer = new VectorTileLayer__default["default"](_objectSpread2({
declutter: true,
visible: false
}, options));
var tilejson = new TileJSON__default['default']({
var tilejson = new TileJSON__default["default"]({
url: url
});
tilejson.on('change', function () {
Expand Down Expand Up @@ -327,6 +337,105 @@ function findAllLevels(features) {
}).reverse();
}

function areaLayer(feature, resolution) {
var properties = feature.getProperties();

if (properties["class"] === 'level') {
return;
}

var color = '#fdfcfa';

if (properties.access && ['no', 'private'].includes(properties.access)) {
color = '#F2F1F0';
} else if (properties.is_poi && properties["class"] !== 'corridor') {
color = '#D4EDFF';
} else if (properties["class"] === 'room') {
color = '#fefee2';
}

var stroke;

if (properties.layer === 'area' && ['area', 'corridor', 'plaform'].includes(properties["class"])) {
stroke = new Stroke__default["default"]({
color: '#bfbfbf',
width: 1
});
}

if (properties.layer === 'area' && properties["class"] === 'column') {
stroke = new Fill__default["default"]({
color: '#bfbfbf'
});
}

if (properties.layer === 'area' && ['room', 'wall'].includes(properties["class"])) {
stroke = new Stroke__default["default"]({
color: 'gray',
width: 2
});
}

return new Style__default["default"]({
fill: new Fill__default["default"]({
color: color
}),
stroke: stroke
});
}

function transportationLayer(feature, resolution) {
return new Style__default["default"]({
stroke: new Stroke__default["default"]({
color: 'gray',
width: 2,
lineDash: [4, 7]
})
});
}

function areanameLayer(feature, resolution) {
return new Style__default["default"]({
text: new Text__default["default"]({
text: feature.getProperties().name,
fill: new Fill__default["default"]({
color: '#666'
})
})
});
}

function poiLayer(feature, resolution) {
return new Style__default["default"]({
text: new Text__default["default"]({
text: feature.getProperties().name,
fill: new Fill__default["default"]({
color: '#666'
})
})
});
}

function defaultStyle(feature, resolution) {
var properties = feature.getProperties();

if (properties.layer === 'area') {
return areaLayer(feature);
}

if (properties.layer === 'transportation') {
return transportationLayer();
}

if (properties.layer === 'area_name') {
return areanameLayer(feature);
}

if (properties.layer === 'poi' && feature.getType() === 'Point') {
return poiLayer(feature);
}
}

/**
* Load the indoor= source and layers in your map.
* @param {object} map the OpenLayers instance of the map
Expand Down Expand Up @@ -367,7 +476,7 @@ var IndoorEqual = /*#__PURE__*/function (_BaseObject) {
_this.map = map;
_this.url = opts.url;
_this.apiKey = opts.apiKey;
_this.styleFunction = null;
_this.styleFunction = defaultStyle;

_this._addLayer();

Expand Down Expand Up @@ -437,8 +546,8 @@ var IndoorEqual = /*#__PURE__*/function (_BaseObject) {
}]);

return IndoorEqual;
}(BaseObject__default['default']);
}(BaseObject__default["default"]);

exports.LevelControl = LevelControl;
exports['default'] = IndoorEqual;
exports["default"] = IndoorEqual;
exports.getLayer = getLayer;
107 changes: 106 additions & 1 deletion dist/mapbox-gl-indoorequal.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { fromLonLat } from 'ol/proj.js';
import TileGrid from 'ol/tilegrid/TileGrid.js';
import { Control } from 'ol/control';
import BaseObject from 'ol/Object';
import Style from 'ol/style/Style';
import Fill from 'ol/style/Fill.js';
import Stroke from 'ol/style/Stroke';
import Text from 'ol/style/Text';

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
Expand Down Expand Up @@ -137,6 +141,8 @@ function _assertThisInitialized(self) {
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}

return _assertThisInitialized(self);
Expand Down Expand Up @@ -314,6 +320,105 @@ function findAllLevels(features) {
}).reverse();
}

function areaLayer(feature, resolution) {
var properties = feature.getProperties();

if (properties["class"] === 'level') {
return;
}

var color = '#fdfcfa';

if (properties.access && ['no', 'private'].includes(properties.access)) {
color = '#F2F1F0';
} else if (properties.is_poi && properties["class"] !== 'corridor') {
color = '#D4EDFF';
} else if (properties["class"] === 'room') {
color = '#fefee2';
}

var stroke;

if (properties.layer === 'area' && ['area', 'corridor', 'plaform'].includes(properties["class"])) {
stroke = new Stroke({
color: '#bfbfbf',
width: 1
});
}

if (properties.layer === 'area' && properties["class"] === 'column') {
stroke = new Fill({
color: '#bfbfbf'
});
}

if (properties.layer === 'area' && ['room', 'wall'].includes(properties["class"])) {
stroke = new Stroke({
color: 'gray',
width: 2
});
}

return new Style({
fill: new Fill({
color: color
}),
stroke: stroke
});
}

function transportationLayer(feature, resolution) {
return new Style({
stroke: new Stroke({
color: 'gray',
width: 2,
lineDash: [4, 7]
})
});
}

function areanameLayer(feature, resolution) {
return new Style({
text: new Text({
text: feature.getProperties().name,
fill: new Fill({
color: '#666'
})
})
});
}

function poiLayer(feature, resolution) {
return new Style({
text: new Text({
text: feature.getProperties().name,
fill: new Fill({
color: '#666'
})
})
});
}

function defaultStyle(feature, resolution) {
var properties = feature.getProperties();

if (properties.layer === 'area') {
return areaLayer(feature);
}

if (properties.layer === 'transportation') {
return transportationLayer();
}

if (properties.layer === 'area_name') {
return areanameLayer(feature);
}

if (properties.layer === 'poi' && feature.getType() === 'Point') {
return poiLayer(feature);
}
}

/**
* Load the indoor= source and layers in your map.
* @param {object} map the OpenLayers instance of the map
Expand Down Expand Up @@ -354,7 +459,7 @@ var IndoorEqual = /*#__PURE__*/function (_BaseObject) {
_this.map = map;
_this.url = opts.url;
_this.apiKey = opts.apiKey;
_this.styleFunction = null;
_this.styleFunction = defaultStyle;

_this._addLayer();

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

0 comments on commit 0475bb5

Please sign in to comment.