More refactoring, stabilizing rotation and direction_gradient

This commit is contained in:
Pieter Vander Vennet 2021-01-04 04:06:21 +01:00
parent 5fec108ba2
commit 778044d0fb
45 changed files with 656 additions and 640 deletions

View file

@ -5,7 +5,7 @@ import {Utils} from "../../Utils";
import Svg from "../../Svg";
import Img from "../../UI/Base/Img";
export class GeoLocationHandler extends UIElement {
export default class GeoLocationHandler extends UIElement {
private readonly _isActive: UIEventSource<boolean> = new UIEventSource<boolean>(false);
private readonly _permission: UIEventSource<string> = new UIEventSource<string>("");
@ -13,17 +13,14 @@ export class GeoLocationHandler extends UIElement {
private readonly _hasLocation: UIEventSource<boolean>;
private readonly _currentGPSLocation: UIEventSource<{ latlng: any; accuracy: number }>;
private readonly _leafletMap: UIEventSource<L.Map>;
private readonly _featureSwitch: UIEventSource<boolean>;
constructor(currentGPSLocation: UIEventSource<{ latlng: any; accuracy: number }>,
leafletMap: UIEventSource<L.Map>,
featureSwitch: UIEventSource<boolean>) {
leafletMap: UIEventSource<L.Map>) {
super(undefined);
this._currentGPSLocation = currentGPSLocation;
this._leafletMap = leafletMap;
this._featureSwitch = featureSwitch;
this._hasLocation = currentGPSLocation.map((location) => location !== undefined);
var self = this;
const self = this;
import("../../vendor/Leaflet.AccuratePosition.js").then(() => {
self.init();
})
@ -92,10 +89,6 @@ export class GeoLocationHandler extends UIElement {
}
InnerRender(): string {
if (!this._featureSwitch.data) {
return "";
}
if (this._hasLocation.data) {
return Svg.crosshair_blue_img;
}
@ -124,7 +117,7 @@ export class GeoLocationHandler extends UIElement {
private StartGeolocating(zoomlevel = 19) {
const self = this;
const map : any = this._leafletMap.data;
const map: any = this._leafletMap.data;
if (self._permission.data === "denied") {
return "";
}

View file

@ -8,14 +8,14 @@ import Img from "../../UI/Base/Img";
* The stray-click-hanlders adds a marker to the map if no feature was clicked.
* Shows the given uiToShow-element in the messagebox
*/
export class StrayClickHandler {
export default class StrayClickHandler {
private _lastMarker;
private _uiToShow: (() => UIElement);
constructor(
lastClickLocation: UIEventSource<{ lat: number, lon:number }>,
lastClickLocation: UIEventSource<{ lat: number, lon: number }>,
selectedElement: UIEventSource<string>,
filteredLayers: UIEventSource<{ readonly isDisplayed: UIEventSource<boolean>}[]>,
filteredLayers: UIEventSource<{ readonly isDisplayed: UIEventSource<boolean> }[]>,
leafletMap: UIEventSource<L.Map>,
fullscreenMessage: UIEventSource<UIElement>,
uiToShow: (() => UIElement)) {
@ -23,14 +23,14 @@ export class StrayClickHandler {
const self = this;
filteredLayers.data.forEach((filteredLayer) => {
filteredLayer.isDisplayed.addCallback(isEnabled => {
if(isEnabled && self._lastMarker && leafletMap.data !== undefined){
if (isEnabled && self._lastMarker && leafletMap.data !== undefined) {
// When a layer is activated, we remove the 'last click location' in order to force the user to reclick
// This reclick might be at a location where a feature now appeared...
leafletMap.data.removeLayer(self._lastMarker);
leafletMap.data.removeLayer(self._lastMarker);
}
})
})
lastClickLocation.addCallback(function (lastClick) {
selectedElement.setData(undefined);

View file

@ -38,6 +38,7 @@ export default class UpdateFromOverpass implements FeatureSource{
location: UIEventSource<Loc>,
layoutToUse: UIEventSource<LayoutConfig>,
leafletMap: UIEventSource<L.Map>) {
console.log("Crating overpass updater")
this._location = location;
this._layoutToUse = layoutToUse;
this._leafletMap = leafletMap;