Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(map-proximity): keep radius distance into storage #1216

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<div class="radius-unit">

<mat-form-field appearance="outline" class="measure-field" floatLabel="always">
<mat-form-field appearance="outline" class="radius-field" floatLabel="always">
<mat-label>{{'igo.integration.map-proximity-tool.radiusM' | translate}}</mat-label>
<input type="number" pattern="[0-9]*" [(ngModel)]="maxDistance" matInput placeholder="{{'igo.integration.map-proximity-tool.radiusM' | translate}}">
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ mat-form-field.igo-input-container { width: 60%; padding: 0px 15px; };
width: 90%;
margin-left: 2px;
padding: 5px;
mat-form-field.radius-field {
display: flex;
flex-flow: column nowrap;
width: 100%;
}
}

.radius-field {

display: flex;
flex-flow: column nowrap;
width: 60%;
}
.title-container {
padding: 10px;
}
Expand Down
11 changes: 9 additions & 2 deletions packages/integration/src/lib/map/map-proximity.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import olVectorSource from 'ol/source/Vector';
import Geometry from 'ol/geom/Geometry';
import olLineString from 'ol/geom/LineString';
import * as olProj from 'ol/proj';
import { StorageService } from '@igo2/core';
/**
* Service that holds the state of the direction module
*/
Expand All @@ -24,8 +25,11 @@ import * as olProj from 'ol/proj';
})
export class MapProximityState {

private defaultProximityRadiusValue: number = 30;

public enabled$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
public proximityRadiusValue$: BehaviorSubject<number> = new BehaviorSubject<number>(30);
public proximityRadiusValue$: BehaviorSubject<number> = new BehaviorSubject<number>(
this.storageService.get('mapProximityRadius') as number || this.defaultProximityRadiusValue);
public proximitylocationType$: BehaviorSubject<string> = new BehaviorSubject<string>('geolocation');
public proximityFeatureStore: FeatureStore<Feature> = new FeatureStore<Feature>([], { map: this.mapState.map });
private subs$$: Subscription[] = [];
Expand All @@ -35,7 +39,9 @@ export class MapProximityState {
return this.mapState.map;
}

constructor(private mapState: MapState) {
constructor(
private mapState: MapState,
private storageService: StorageService) {

this.mapState.map.ol.once('rendercomplete', () => {
this.subscribeProximityMonitor();
Expand All @@ -59,6 +65,7 @@ export class MapProximityState {
const currentPos = this.map.geolocationController.position$.value;
const locationType = bunch[1];
const proximityRadiusValue = bunch[2];
this.storageService.set('mapProximityRadius', proximityRadiusValue || this.defaultProximityRadiusValue);

if (!enabled) {
return;
Expand Down