Update openlayers to v6.3.1 (#73)

* Update openlayers to v6.3.1 and get existing source working with new version

* Organize ol source files a bit

Co-authored-by: erictran <eric.tran@flightaware.com>
This commit is contained in:
eric1tran 2020-07-21 11:32:39 -05:00 committed by GitHub
parent 0dae3e4b4a
commit f2f19d49fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 840 additions and 29 deletions

View File

@ -8,11 +8,11 @@
<script src="jquery/jquery-ui-1.11.4.min.js"></script>
<script src="jquery/plugins/jquery.validate.min.js"></script>
<link rel="stylesheet" href="ol/ol-4.4.2.css" type="text/css" />
<script src="ol/ol-4.4.2.js" type="text/javascript"></script>
<link rel="stylesheet" href="ol/v6.3.1/ol.css" type="text/css" />
<script src="ol/v6.3.1/ol.js" type="text/javascript"></script>
<link rel="stylesheet" href="ol/ol3-layerswitcher.css" type="text/css"/>
<script src="ol/ol3-layerswitcher.js" type="text/javascript"></script>
<link rel="stylesheet" href="ol/ol-layerswitcher.css" type="text/css"/>
<script src="ol/ol-layerswitcher.js" type="text/javascript"></script>
<script type="text/javascript" src="config.js?v=3.8.1"></script>
<script type="text/javascript" src="markers.js?v=3.8.1"></script>

View File

@ -0,0 +1,131 @@
.layer-switcher.shown.ol-control {
background-color: transparent;
}
.layer-switcher.shown.ol-control:hover {
background-color: transparent;
}
.layer-switcher {
position: absolute;
top: 3.5em;
right: 0.5em;
text-align: left;
}
.layer-switcher.shown {
bottom: 3em;
}
.layer-switcher .panel {
padding: 0 1em 0 0;
margin: 0;
border: 4px solid #eee;
border-radius: 4px;
background-color: white;
display: none;
max-height: 100%;
overflow-y: auto;
}
.layer-switcher.shown .panel {
display: block;
}
.layer-switcher button {
float: right;
width: 38px;
height: 38px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACE1BMVEX///8A//8AgICA//8AVVVAQID///8rVVVJtttgv98nTmJ2xNgkW1ttyNsmWWZmzNZYxM4gWGgeU2JmzNNr0N1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ZMLyHL4Y0fe319idMNgMMp+zWVSybUed/+/h7I4wRAG1W6XDy4XmjR9HnzvDRZXUAYDFOhC1S/Hh+fIXxen+eO+AKqbs+wAo30zDTDvDxKoJN88sjUzDFAvBzEUGFsnADoIvAJzoh2BZ8sner+Ke/vwECuQAAAABJRU5ErkJggg==') /*logo.png*/;
background-repeat: no-repeat;
background-position: 2px;
background-color: white;
border: none;
}
.layer-switcher.shown button {
display: none;
}
.layer-switcher.shown.activationModeClick > button {
display: block;
background-image: unset;
color: black;
right: 2px;
position: absolute;
}
.layer-switcher button:focus, .layer-switcher button:hover {
background-color: white;
}
.layer-switcher ul {
padding-left: 2em;
list-style: none;
}
.layer-switcher li.group > label {
font-weight: bold;
}
.layer-switcher li.layer {
display: table;
}
.layer-switcher li.layer label, .layer-switcher li.layer input {
display: table-cell;
vertical-align: middle;
}
.layer-switcher label.disabled {
opacity:0.4;
}
.layer-switcher input {
margin: 4px;
}
.layer-switcher.touch ::-webkit-scrollbar {
width: 4px;
}
.layer-switcher.touch ::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
}
.layer-switcher.touch ::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
.layer-switcher .group button {
display: inline-block;
vertical-align: top;
float: none;
width: 16px;
height: 16px;
background-position: center 2px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAW0lEQVR4nGNgGAWMyBwXFxcGBgaGeii3EU0tXHzPnj1wQRYsihqQ+I0ExDEMQAYNONgoAN0AmMkNaDSyQSheY8JiaCMOGzE04zIAmyFYNTMw4A+DRhzsUUBtAADw4BCeIZkGdwAAAABJRU5ErkJggg==');
-webkit-transition: -webkit-transform .2s ease-in-out;
-ms-transition: -ms-transform .2s ease-in-out;
transition: transform .2s ease-in-out;
}
.layer-switcher .group.layer-switcher-close button {
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
}
li.group.layer-switcher-fold {
margin-left: -18px;
}
.layer-switcher .group.layer-switcher-fold > ul {
padding-left: 3em;
}
.layer-switcher .group.layer-switcher-fold.layer-switcher-close > ul {
overflow: hidden;
height: 0;
}

View File

@ -0,0 +1,664 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/control/Control'), require('ol/Observable')) :
typeof define === 'function' && define.amd ? define(['ol/control/Control', 'ol/Observable'], factory) :
(global.LayerSwitcher = factory(global.ol.control.Control,global.ol.Observable));
}(this, (function (Control,ol_Observable) { 'use strict';
Control = 'default' in Control ? Control['default'] : Control;
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var CSS_PREFIX = 'layer-switcher-';
/**
* OpenLayers Layer Switcher Control.
* See [the examples](./examples) for usage.
* @constructor
* @extends {ol/control/Control~Control}
* @param {Object} opt_options Control options, extends ol/control/Control~Control#options adding:
* @param {String} opt_options.activationMode Event to use on the button to collapse or expand the panel.
* `'mouseover'` (default) the layerswitcher panel stays expanded while button or panel are hovered.
* `'click'` a click on the button toggles the layerswitcher visibility.
* @param {String} opt_options.collapseLabel Text label to use for the expanded layerswitcher button. E.g.:
* `'»'` (default) or `'\u00BB'`, `'-'` or `'\u2212'`. Not visible if activation mode is `'mouseover'`
* @param {String} opt_options.label Text label to use for the collapsed layerswitcher button. E.g.:
* `''` (default), `'«'` or `'\u00AB'`, `'+'`.
* @param {String} opt_options.tipLabel the button tooltip.
* @param {String} opt_options.groupSelectStyle either `'none'` - groups don't get a checkbox,
* `'children'` (default) groups have a checkbox and affect child visibility or
* `'group'` groups have a checkbox but do not alter child visibility (like QGIS).
* @param {boolean} opt_options.reverse Reverse the layer order. Defaults to true.
*/
var LayerSwitcher = function (_Control) {
inherits(LayerSwitcher, _Control);
function LayerSwitcher(opt_options) {
classCallCheck(this, LayerSwitcher);
var options = opt_options || {};
var tipLabel = options.tipLabel ? options.tipLabel : 'Legend';
var element = document.createElement('div');
var _this = possibleConstructorReturn(this, (LayerSwitcher.__proto__ || Object.getPrototypeOf(LayerSwitcher)).call(this, { element: element, target: options.target }));
_this.activationMode = options.activationMode || 'mouseover';
var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\xBB';
var label = options.label !== undefined ? options.label : '';
_this.groupSelectStyle = LayerSwitcher.getGroupSelectStyle(options.groupSelectStyle);
_this.reverse = options.reverse !== false;
_this.mapListeners = [];
_this.hiddenClassName = 'ol-unselectable ol-control layer-switcher';
if (LayerSwitcher.isTouchDevice_()) {
_this.hiddenClassName += ' touch';
}
_this.shownClassName = 'shown';
element.className = _this.hiddenClassName;
var button = document.createElement('button');
button.setAttribute('title', tipLabel);
element.appendChild(button);
_this.panel = document.createElement('div');
_this.panel.className = 'panel';
element.appendChild(_this.panel);
LayerSwitcher.enableTouchScroll_(_this.panel);
var this_ = _this;
button.textContent = label;
if (_this.activationMode == 'click') {
element.classList.add('activationModeClick');
button.onclick = function (e) {
e = e || window.event;
if (this_.element.classList.contains(this_.shownClassName)) {
this_.hidePanel();
button.textContent = label;
} else {
this_.showPanel();
button.textContent = collapseLabel;
}
e.preventDefault();
};
return possibleConstructorReturn(_this);
}
button.onmouseover = function (e) {
this_.showPanel();
};
button.onclick = function (e) {
e = e || window.event;
this_.showPanel();
e.preventDefault();
};
this_.panel.onmouseout = function (e) {
e = e || window.event;
if (!this_.panel.contains(e.toElement || e.relatedTarget)) {
this_.hidePanel();
}
};
return _this;
}
/**
* Set the map instance the control is associated with.
* @param {ol/Map~Map} map The map instance.
*/
createClass(LayerSwitcher, [{
key: 'setMap',
value: function setMap(map) {
// Clean up listeners associated with the previous map
for (var i = 0, key; i < this.mapListeners.length; i++) {
ol_Observable.unByKey(this.mapListeners[i]);
}
this.mapListeners.length = 0;
// Wire up listeners etc. and store reference to new map
get(LayerSwitcher.prototype.__proto__ || Object.getPrototypeOf(LayerSwitcher.prototype), 'setMap', this).call(this, map);
if (map) {
this.renderPanel();
if (this.activationMode == 'click') return;
var this_ = this;
this.mapListeners.push(map.on('pointerdown', function () {
this_.hidePanel();
}));
}
}
/**
* Show the layer panel.
*/
}, {
key: 'showPanel',
value: function showPanel() {
this.dispatchEvent({ type: 'showPanel' });
if (!this.element.classList.contains(this.shownClassName)) {
this.element.classList.add(this.shownClassName);
this.renderPanel();
}
}
/**
* Hide the layer panel.
*/
}, {
key: 'hidePanel',
value: function hidePanel() {
this.dispatchEvent({ type: 'hidePanel' });
if (this.element.classList.contains(this.shownClassName)) {
this.element.classList.remove(this.shownClassName);
}
}
/**
* Re-draw the layer panel to represent the current state of the layers.
*/
}, {
key: 'renderPanel',
value: function renderPanel() {
this.dispatchEvent({ type: 'render' });
LayerSwitcher.renderPanel(this.getMap(), this.panel, { groupSelectStyle: this.groupSelectStyle, reverse: this.reverse });
this.dispatchEvent({ type: 'rendercomplete' });
}
/**
* **Static** Re-draw the layer panel to represent the current state of the layers.
* @param {ol/Map~Map} map The OpenLayers Map instance to render layers for
* @param {Element} panel The DOM Element into which the layer tree will be rendered
*/
}], [{
key: 'renderPanel',
value: function renderPanel(map, panel, options) {
// Create the event.
var render_event = new Event('render');
// Dispatch the event.
panel.dispatchEvent(render_event);
options = options || {};
options.groupSelectStyle = LayerSwitcher.getGroupSelectStyle(options.groupSelectStyle);
LayerSwitcher.ensureTopVisibleBaseLayerShown_(map);
while (panel.firstChild) {
panel.removeChild(panel.firstChild);
}
// Reset indeterminate state for all layers and groups before
// applying based on groupSelectStyle
LayerSwitcher.forEachRecursive(map, function (l, idx, a) {
l.set('indeterminate', false);
});
if (options.groupSelectStyle === 'children' || options.groupSelectStyle === 'none') {
// Set visibile and indeterminate state of groups based on
// their children's visibility
LayerSwitcher.setGroupVisibility(map);
} else if (options.groupSelectStyle === 'group') {
// Set child indetermiate state based on their parent's visibility
LayerSwitcher.setChildVisibility(map);
}
var ul = document.createElement('ul');
panel.appendChild(ul);
// passing two map arguments instead of lyr as we're passing the map as the root of the layers tree
LayerSwitcher.renderLayers_(map, map, ul, options, function render(changedLyr) {
// console.log('render');
LayerSwitcher.renderPanel(map, panel, options);
});
// Create the event.
var rendercomplete_event = new Event('rendercomplete');
// Dispatch the event.
panel.dispatchEvent(rendercomplete_event);
}
}, {
key: 'isBaseGroup',
value: function isBaseGroup(lyr) {
var lyrs = lyr.getLayers ? lyr.getLayers().getArray() : [];
return lyrs.length && lyrs[0].get('type') === 'base';
}
}, {
key: 'setGroupVisibility',
value: function setGroupVisibility(map) {
// Get a list of groups, with the deepest first
var groups = LayerSwitcher.getGroupsAndLayers(map, function (l) {
return l.getLayers && !l.get('combine') && !LayerSwitcher.isBaseGroup(l);
}).reverse();
// console.log(groups.map(g => g.get('title')));
groups.forEach(function (group) {
// TODO Can we use getLayersArray, is it public in the esm build?
var descendantVisibility = group.getLayersArray().map(function (l) {
var state = l.getVisible();
// console.log('>', l.get('title'), state);
return state;
});
// console.log(descendantVisibility);
if (descendantVisibility.every(function (v) {
return v === true;
})) {
group.setVisible(true);
group.set('indeterminate', false);
} else if (descendantVisibility.every(function (v) {
return v === false;
})) {
group.setVisible(false);
group.set('indeterminate', false);
} else {
group.setVisible(true);
group.set('indeterminate', true);
}
});
}
}, {
key: 'setChildVisibility',
value: function setChildVisibility(map) {
// console.log('setChildVisibility');
var groups = LayerSwitcher.getGroupsAndLayers(map, function (l) {
return l.getLayers && !l.get('combine') && !LayerSwitcher.isBaseGroup(l);
});
groups.forEach(function (group) {
// console.log(group.get('title'));
var groupVisible = group.getVisible();
var groupIndeterminate = group.get('indeterminate');
group.getLayers().getArray().forEach(function (l) {
// console.log('>', l.get('title'));
l.set('indeterminate', false);
if ((!groupVisible || groupIndeterminate) && l.getVisible()) {
l.set('indeterminate', true);
}
});
});
}
/**
* **Static** Ensure only the top-most base layer is visible if more than one is visible.
* @param {ol/Map~Map} map The map instance.
* @private
*/
}, {
key: 'ensureTopVisibleBaseLayerShown_',
value: function ensureTopVisibleBaseLayerShown_(map) {
var lastVisibleBaseLyr;
LayerSwitcher.forEachRecursive(map, function (l, idx, a) {
if (l.get('type') === 'base' && l.getVisible()) {
lastVisibleBaseLyr = l;
}
});
if (lastVisibleBaseLyr) LayerSwitcher.setVisible_(map, lastVisibleBaseLyr, true);
}
}, {
key: 'getGroupsAndLayers',
value: function getGroupsAndLayers(lyr, filterFn) {
var layers = [];
filterFn = filterFn || function (l, idx, a) {
return true;
};
LayerSwitcher.forEachRecursive(lyr, function (l, idx, a) {
if (l.get('title')) {
if (filterFn(l, idx, a)) {
layers.push(l);
}
}
});
return layers;
}
/**
* **Static** Toggle the visible state of a layer.
* Takes care of hiding other layers in the same exclusive group if the layer
* is toggle to visible.
* @private
* @param {ol/Map~Map} map The map instance.
* @param {ol/layer/Base~BaseLayer} The layer whose visibility will be toggled.
*/
}, {
key: 'setVisible_',
value: function setVisible_(map, lyr, visible, groupSelectStyle) {
// console.log(lyr.get('title'), visible, groupSelectStyle);
lyr.setVisible(visible);
if (visible && lyr.get('type') === 'base') {
// Hide all other base layers regardless of grouping
LayerSwitcher.forEachRecursive(map, function (l, idx, a) {
if (l != lyr && l.get('type') === 'base') {
l.setVisible(false);
}
});
}
if (lyr.getLayers && !lyr.get('combine') && groupSelectStyle === 'children') {
lyr.getLayers().forEach(function (l) {
LayerSwitcher.setVisible_(map, l, lyr.getVisible(), groupSelectStyle);
});
}
}
/**
* **Static** Render all layers that are children of a group.
* @private
* @param {ol/Map~Map} map The map instance.
* @param {ol/layer/Base~BaseLayer} lyr Layer to be rendered (should have a title property).
* @param {Number} idx Position in parent group list.
*/
}, {
key: 'renderLayer_',
value: function renderLayer_(map, lyr, idx, options, render) {
var li = document.createElement('li');
var lyrTitle = lyr.get('title');
var checkboxId = LayerSwitcher.uuid();
var label = document.createElement('label');
if (lyr.getLayers && !lyr.get('combine')) {
var isBaseGroup = LayerSwitcher.isBaseGroup(lyr);
li.classList.add('group');
if (isBaseGroup) {
li.classList.add(CSS_PREFIX + 'base-group');
}
// Group folding
if (lyr.get('fold')) {
li.classList.add(CSS_PREFIX + 'fold');
li.classList.add(CSS_PREFIX + lyr.get('fold'));
var btn = document.createElement('button');
btn.onclick = function (e) {
e = e || window.event;
LayerSwitcher.toggleFold_(lyr, li);
e.preventDefault();
};
li.appendChild(btn);
}
if (!isBaseGroup && options.groupSelectStyle != 'none') {
var _input = document.createElement('input');
_input.type = 'checkbox';
_input.id = checkboxId;
_input.checked = lyr.getVisible();
_input.indeterminate = lyr.get('indeterminate');
_input.onchange = function (e) {
LayerSwitcher.setVisible_(map, lyr, e.target.checked, options.groupSelectStyle);
render(lyr);
};
li.appendChild(_input);
label.htmlFor = checkboxId;
}
label.innerHTML = lyrTitle;
li.appendChild(label);
var ul = document.createElement('ul');
li.appendChild(ul);
LayerSwitcher.renderLayers_(map, lyr, ul, options, render);
} else {
li.className = 'layer';
var input = document.createElement('input');
if (lyr.get('type') === 'base') {
input.type = 'radio';
input.name = 'base';
} else {
input.type = 'checkbox';
}
input.id = checkboxId;
input.checked = lyr.get('visible');
input.indeterminate = lyr.get('indeterminate');
input.onchange = function (e) {
LayerSwitcher.setVisible_(map, lyr, e.target.checked, options.groupSelectStyle);
render(lyr);
};
li.appendChild(input);
label.htmlFor = checkboxId;
label.innerHTML = lyrTitle;
var rsl = map.getView().getResolution();
if (rsl > lyr.getMaxResolution() || rsl < lyr.getMinResolution()) {
label.className += ' disabled';
}
li.appendChild(label);
}
return li;
}
/**
* **Static** Render all layers that are children of a group.
* @private
* @param {ol/Map~Map} map The map instance.
* @param {ol/layer/Group~LayerGroup} lyr Group layer whose children will be rendered.
* @param {Element} elm DOM element that children will be appended to.
*/
}, {
key: 'renderLayers_',
value: function renderLayers_(map, lyr, elm, options, render) {
var lyrs = lyr.getLayers().getArray().slice();
if (options.reverse) lyrs = lyrs.reverse();
for (var i = 0, l; i < lyrs.length; i++) {
l = lyrs[i];
if (l.get('title')) {
elm.appendChild(LayerSwitcher.renderLayer_(map, l, i, options, render));
}
}
}
/**
* **Static** Call the supplied function for each layer in the passed layer group
* recursing nested groups.
* @param {ol/layer/Group~LayerGroup} lyr The layer group to start iterating from.
* @param {Function} fn Callback which will be called for each `ol/layer/Base~BaseLayer`
* found under `lyr`. The signature for `fn` is the same as `ol/Collection~Collection#forEach`
*/
}, {
key: 'forEachRecursive',
value: function forEachRecursive(lyr, fn) {
lyr.getLayers().forEach(function (lyr, idx, a) {
fn(lyr, idx, a);
if (lyr.getLayers) {
LayerSwitcher.forEachRecursive(lyr, fn);
}
});
}
/**
* **Static** Generate a UUID
* Adapted from http://stackoverflow.com/a/2117523/526860
* @returns {String} UUID
*/
}, {
key: 'uuid',
value: function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
}
/**
* @private
* @desc Apply workaround to enable scrolling of overflowing content within an
* element. Adapted from https://gist.github.com/chrismbarr/4107472
*/
}, {
key: 'enableTouchScroll_',
value: function enableTouchScroll_(elm) {
if (LayerSwitcher.isTouchDevice_()) {
var scrollStartPos = 0;
elm.addEventListener("touchstart", function (event) {
scrollStartPos = this.scrollTop + event.touches[0].pageY;
}, false);
elm.addEventListener("touchmove", function (event) {
this.scrollTop = scrollStartPos - event.touches[0].pageY;
}, false);
}
}
/**
* @private
* @desc Determine if the current browser supports touch events. Adapted from
* https://gist.github.com/chrismbarr/4107472
*/
}, {
key: 'isTouchDevice_',
value: function isTouchDevice_() {
try {
document.createEvent("TouchEvent");
return true;
} catch (e) {
return false;
}
}
/**
* Fold/unfold layer group
* @private
*/
}, {
key: 'toggleFold_',
value: function toggleFold_(lyr, li) {
li.classList.remove(CSS_PREFIX + lyr.get('fold'));
lyr.set('fold', lyr.get('fold') === 'open' ? 'close' : 'open');
li.classList.add(CSS_PREFIX + lyr.get('fold'));
}
/**
* If a valid groupSelectStyle value is not provided then return the default
* @private
*/
}, {
key: 'getGroupSelectStyle',
value: function getGroupSelectStyle(groupSelectStyle) {
return ['none', 'children', 'group'].indexOf(groupSelectStyle) >= 0 ? groupSelectStyle : 'children';
}
}]);
return LayerSwitcher;
}(Control);
if (window.ol && window.ol.control) {
window.ol.control.LayerSwitcher = LayerSwitcher;
}
return LayerSwitcher;
})));

View File

@ -0,0 +1,2 @@
.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-step-marker{width:1px;height:15px;background-color:#000;float:right;z-Index:10}.ol-scale-step-text{position:absolute;bottom:-5px;font-size:12px;z-Index:11;color:#000;text-shadow:-2px 0 #fff,0 2px #fff,2px 0 #fff,0 -2px #fff}.ol-scale-text{position:absolute;font-size:14px;text-align:center;bottom:25px;color:#000;text-shadow:-2px 0 #fff,0 2px #fff,2px 0 #fff,0 -2px #fff}.ol-scale-singlebar{position:relative;height:10px;z-Index:9;border:1px solid #000}.ol-unsupported{display:none}.ol-unselectable,.ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-overlaycontainer,.ol-overlaycontainer-stopevent{pointer-events:none}.ol-overlaycontainer-stopevent>*,.ol-overlaycontainer>*{pointer-events:auto}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{position:absolute;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px}.ol-control:hover{background-color:rgba(255,255,255,.6)}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-control button span{pointer-events:none}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em)}.ol-attribution ul{margin:0;padding:0 .5em;color:#000;text-shadow:0 0 2px #fff}.ol-attribution li{display:inline;list-style:none}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button,.ol-attribution ul{display:inline-block}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:inline-block}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}
/*# sourceMappingURL=ol.css.map */

View File

@ -0,0 +1 @@
{"version":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KAAM,EACN,cAAe,EAAE,IAAI,EAAE,EAEzB,oCACA,uBACE,QAAS,aAEX,oCACE,OAAQ,IAAI,MAAM,QAClB,OAAQ,MACR,OAAQ,IACR,MAAO,MAET,0CACE,OAAQ,IACR,KAAM,IACN,SAAU,SAEZ,iDACA,wCACE,QAAS,KAEX,mCACE,WAAY,qBAEd,oBACE,OAAQ,IAAI,OAAO,kBAGrB,0CACE,OAAQ"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -496,8 +496,7 @@ PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
this.last_position_time = receiver_timestamp - data.seen_pos;
if (SitePosition !== null) {
var WGS84 = new ol.Sphere(6378137);
this.sitedist = WGS84.haversineDistance(SitePosition, this.position);
this.sitedist = ol.sphere.getDistance(SitePosition, this.position);
}
this.position_from_mlat = false;

View File

@ -49,6 +49,7 @@ var MessageRate = 0;
var NBSP='\u00a0';
var layers;
var layerGroup;
// piaware vs flightfeeder
var isFlightFeeder = false;
@ -524,18 +525,22 @@ function make_geodesic_circle(center, radius, points) {
var angularDistance = radius / 6378137.0;
var lon1 = center[0] * Math.PI / 180.0;
var lat1 = center[1] * Math.PI / 180.0;
var geom = new ol.geom.LineString();
var geom;
for (var i = 0; i <= points; ++i) {
var bearing = i * 2 * Math.PI / points;
var bearing = i * 2 * Math.PI / points;
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(angularDistance) +
Math.cos(lat1)*Math.sin(angularDistance)*Math.cos(bearing) );
var lon2 = lon1 + Math.atan2(Math.sin(bearing)*Math.sin(angularDistance)*Math.cos(lat1),
Math.cos(angularDistance)-Math.sin(lat1)*Math.sin(lat2));
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(angularDistance) +
Math.cos(lat1)*Math.sin(angularDistance)*Math.cos(bearing) );
var lon2 = lon1 + Math.atan2(Math.sin(bearing)*Math.sin(angularDistance)*Math.cos(lat1),
Math.cos(angularDistance)-Math.sin(lat1)*Math.sin(lat2));
lat2 = lat2 * 180.0 / Math.PI;
lon2 = lon2 * 180.0 / Math.PI;
lat2 = lat2 * 180.0 / Math.PI;
lon2 = lon2 * 180.0 / Math.PI;
if (!geom) {
geom = new ol.geom.LineString([[lon2, lat2]]);
} else {
geom.appendCoordinate([lon2, lat2]);
}
}
return geom;
}
@ -612,7 +617,11 @@ function initialize_map() {
var foundType = false;
var baseCount = 0;
ol.control.LayerSwitcher.forEachRecursive(layers, function(lyr) {
layerGroup = new ol.layer.Group({
layers: layers
})
ol.control.LayerSwitcher.forEachRecursive(layerGroup, function(lyr) {
if (!lyr.get('name'))
return;
@ -644,7 +653,7 @@ function initialize_map() {
})
if (!foundType) {
ol.control.LayerSwitcher.forEachRecursive(layers, function(lyr) {
ol.control.LayerSwitcher.forEachRecursive(layerGroup, function(lyr) {
if (foundType)
return;
if (lyr.get('type') === 'base') {
@ -704,11 +713,12 @@ function initialize_map() {
function(feature, layer) {
return feature.hex;
},
null,
function(layer) {
return (layer === iconsLayer);
},
null);
{
layerFilter: function(layer) {
return (layer === iconsLayer);
},
hitTolerance: 5,
});
if (hex) {
selectPlaneByHex(hex, (evt.type === 'dblclick'));
adjustSelectedInfoBlockPosition();
@ -726,11 +736,12 @@ function initialize_map() {
function(feature, layer) {
return feature.hex;
},
null,
function(layer) {
return (layer === iconsLayer);
},
null
{
layerFilter: function(layer) {
return (layer === iconsLayer);
},
hitTolerance: 5,
}
);
if (hex) {
@ -1987,8 +1998,8 @@ function getAirframesModeSLink(code) {
// takes in an elemnt jQuery path and the OL3 layer name and toggles the visibility based on clicking it
function toggleLayer(element, layer) {
// set initial checked status
ol.control.LayerSwitcher.forEachRecursive(layers, function(lyr) {
// set initial checked status
ol.control.LayerSwitcher.forEachRecursive(layerGroup, function(lyr) {
if (lyr.get('name') === layer && lyr.getVisible()) {
$(element).addClass('settingsCheckboxChecked');
}
@ -1998,7 +2009,7 @@ function toggleLayer(element, layer) {
if ($(element).hasClass('settingsCheckboxChecked')) {
visible = true;
}
ol.control.LayerSwitcher.forEachRecursive(layers, function(lyr) {
ol.control.LayerSwitcher.forEachRecursive(layerGroup, function(lyr) {
if (lyr.get('name') === layer) {
if (visible) {
lyr.setVisible(false);