Minor cleanups
This commit is contained in:
parent
ec01086049
commit
c506f8d98e
@ -409,7 +409,7 @@ button > * {
|
|||||||
right: 8px;
|
right: 8px;
|
||||||
}
|
}
|
||||||
.ol-popup-closer:after {
|
.ol-popup-closer:after {
|
||||||
content: "✖";
|
content: "×";
|
||||||
}
|
}
|
||||||
|
|
||||||
#switcher {
|
#switcher {
|
||||||
|
@ -253,12 +253,9 @@ export default class OpenLayersApi {
|
|||||||
popupContent.id = 'popup-content';
|
popupContent.id = 'popup-content';
|
||||||
popupContainer.appendChild(popupContent);
|
popupContainer.appendChild(popupContent);
|
||||||
const popupCloser = document.createElement('a');
|
const popupCloser = document.createElement('a');
|
||||||
popupCloser.id = 'popup-closer';
|
|
||||||
popupCloser.className = 'ol-popup-closer';
|
popupCloser.className = 'ol-popup-closer';
|
||||||
popupCloser.href = '#';
|
|
||||||
popupContainer.appendChild(popupCloser);
|
popupContainer.appendChild(popupCloser);
|
||||||
|
|
||||||
|
|
||||||
this.popup = new ol.Overlay({
|
this.popup = new ol.Overlay({
|
||||||
element: popupContainer,
|
element: popupContainer,
|
||||||
autoPan: true,
|
autoPan: true,
|
||||||
@ -347,6 +344,9 @@ export default class OpenLayersApi {
|
|||||||
switcherContent.id = 'switcher-content';
|
switcherContent.id = 'switcher-content';
|
||||||
switcherContent.className = 'ol-layerswitcher';
|
switcherContent.className = 'ol-layerswitcher';
|
||||||
switcher.appendChild(switcherContent);
|
switcher.appendChild(switcherContent);
|
||||||
|
const switcherCloser = document.createElement('a');
|
||||||
|
switcherCloser.className = 'ol-popup-closer';
|
||||||
|
switcher.appendChild(switcherCloser);
|
||||||
|
|
||||||
this.map.getLayers().forEach(/** @param {Layer} _layer */(_layer) => {
|
this.map.getLayers().forEach(/** @param {Layer} _layer */(_layer) => {
|
||||||
const layerLabel = document.createElement('label');
|
const layerLabel = document.createElement('label');
|
||||||
@ -387,6 +387,7 @@ export default class OpenLayersApi {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
switcherCloser.addEventListener('click', switcherHandle, false);
|
||||||
switcherButton.addEventListener('click', switcherHandle, false);
|
switcherButton.addEventListener('click', switcherHandle, false);
|
||||||
switcherButton.addEventListener('touchstart', switcherHandle, false);
|
switcherButton.addEventListener('touchstart', switcherHandle, false);
|
||||||
|
|
||||||
|
@ -83,4 +83,12 @@ export default class uPosition {
|
|||||||
hasImage() {
|
hasImage() {
|
||||||
return (this.image != null && this.image.length > 0);
|
return (this.image != null && this.image.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get calculatedSpeed() {
|
||||||
|
return this.seconds ? this.meters / this.seconds : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
get totalSpeed() {
|
||||||
|
return this.totalSeconds ? this.totalMeters / this.totalSeconds : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,19 +82,33 @@ export default class uPositionSet extends uListItem {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch latest position of each user.
|
* Fetch latest position of each user.
|
||||||
* @return {Promise<uPositionSet, Error>}
|
* @return {Promise<void, Error>}
|
||||||
|
*/
|
||||||
|
fetchLatest() {
|
||||||
|
this.clear();
|
||||||
|
return uPositionSet.fetch({ last: true }).then((_positions) => {
|
||||||
|
this.fromJson(_positions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch latest position of each user.
|
||||||
|
* @return {Promise<?uPositionSet, Error>}
|
||||||
*/
|
*/
|
||||||
static fetchLatest() {
|
static fetchLatest() {
|
||||||
return this.fetch({ last: true }).then((_positions) => {
|
|
||||||
if (_positions.length) {
|
|
||||||
const set = new uPositionSet();
|
const set = new uPositionSet();
|
||||||
set.fromJson(_positions);
|
return set.fetchLatest().then(() => {
|
||||||
|
if (set.length) {
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param params
|
||||||
|
* @return {Promise<Object[], Error>}
|
||||||
|
*/
|
||||||
static fetch(params) {
|
static fetch(params) {
|
||||||
return uAjax.get('utils/getpositions.php', params);
|
return uAjax.get('utils/getpositions.php', params);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export default class uUser extends uListItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Promise<uTrack, string>}
|
* @return {Promise<uTrack, Error>}
|
||||||
*/
|
*/
|
||||||
fetchLastPosition() {
|
fetchLastPosition() {
|
||||||
return uTrack.fetchLatest(this);
|
return uTrack.fetchLatest(this);
|
||||||
@ -51,7 +51,7 @@ export default class uUser extends uListItem {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws
|
* @throws
|
||||||
* @return {Promise<uUser[], string>}
|
* @return {Promise<uUser[], Error>}
|
||||||
*/
|
*/
|
||||||
static fetchList() {
|
static fetchList() {
|
||||||
return uAjax.get('utils/getusers.php').then((_users) => {
|
return uAjax.get('utils/getusers.php').then((_users) => {
|
||||||
|
@ -294,24 +294,13 @@ export default class uUtils {
|
|||||||
static openUrl(url) {
|
static openUrl(url) {
|
||||||
window.location.assign(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Error} e
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
static error(e, message) {
|
||||||
|
console.error(`${e.name}: ${e.message} (${e.stack})`);
|
||||||
|
alert(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// seconds to (d) H:M:S
|
|
||||||
Number.prototype.toHMS = function () {
|
|
||||||
let s = this;
|
|
||||||
const d = Math.floor(s / 86400);
|
|
||||||
const h = Math.floor((s % 86400) / 3600);
|
|
||||||
const m = Math.floor(((s % 86400) % 3600) / 60);
|
|
||||||
s = ((s % 86400) % 3600) % 60;
|
|
||||||
return ((d > 0) ? (d + ' d ') : '') + (('00' + h).slice(-2)) + ':' + (('00' + m).slice(-2)) + ':' + (('00' + s).slice(-2)) + '';
|
|
||||||
};
|
|
||||||
|
|
||||||
// meters to km
|
|
||||||
Number.prototype.toKm = function () {
|
|
||||||
return Math.round(this / 10) / 100;
|
|
||||||
};
|
|
||||||
|
|
||||||
// m/s to km/h
|
|
||||||
Number.prototype.toKmH = function () {
|
|
||||||
return Math.round(this * 3600 / 10) / 100;
|
|
||||||
};
|
|
||||||
|
@ -70,22 +70,22 @@ describe('Track tests', () => {
|
|||||||
seconds = 0;
|
seconds = 0;
|
||||||
|
|
||||||
jsonPosition = {
|
jsonPosition = {
|
||||||
'id': posId,
|
id: posId,
|
||||||
'latitude': latitude,
|
latitude: latitude,
|
||||||
'longitude': longitude,
|
longitude: longitude,
|
||||||
'altitude': altitude,
|
altitude: altitude,
|
||||||
'speed': speed,
|
speed: speed,
|
||||||
'bearing': bearing,
|
bearing: bearing,
|
||||||
'timestamp': timestamp,
|
timestamp: timestamp,
|
||||||
'accuracy': accuracy,
|
accuracy: accuracy,
|
||||||
'provider': provider,
|
provider: provider,
|
||||||
'comment': comment,
|
comment: comment,
|
||||||
'image': image,
|
image: image,
|
||||||
'username': username,
|
username: username,
|
||||||
'trackid': trackid,
|
trackid: trackid,
|
||||||
'trackname': trackname,
|
trackname: trackname,
|
||||||
'meters': meters,
|
meters: meters,
|
||||||
'seconds': seconds
|
seconds: seconds
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ foreach ($gpxFiles as $i => $gpxFile) {
|
|||||||
$provider = "gps";
|
$provider = "gps";
|
||||||
if (!empty($point->extensions)) {
|
if (!empty($point->extensions)) {
|
||||||
// parse ulogger extensions
|
// parse ulogger extensions
|
||||||
$ext = $point->extensions->children('ulogger', TRUE);
|
$ext = $point->extensions->children('ulogger', true);
|
||||||
if (count($ext->speed)) { $speed = (double) $ext->speed; }
|
if (count($ext->speed)) { $speed = (double) $ext->speed; }
|
||||||
if (count($ext->bearing)) { $bearing = (double) $ext->bearing; }
|
if (count($ext->bearing)) { $bearing = (double) $ext->bearing; }
|
||||||
if (count($ext->accuracy)) { $accuracy = (int) $ext->accuracy; }
|
if (count($ext->accuracy)) { $accuracy = (int) $ext->accuracy; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user