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

fix(geo): adapt numbers with unit and solve show hide ditanse and area #1504

Merged
merged 6 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 5 additions & 6 deletions packages/geo/src/lib/measure/measurer/measurer.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ $slide-toggle-width: 60px;
padding: 4px 8px;
white-space: nowrap;
}
.igo-map-tooltip-hidden {
display: none;
}
.igo-map-tooltip-measure-by-display {
display: none;
}
}

::ng-deep .igo-map-tooltip-hidden,
.igo-map-tooltip-measure-by-display {
display: none;
}
81 changes: 44 additions & 37 deletions packages/geo/src/lib/measure/measurer/measurer.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { DOCUMENT } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Inject,
Input,
OnDestroy,
OnInit,
Expand Down Expand Up @@ -292,7 +294,8 @@ export class MeasurerComponent implements OnInit, OnDestroy {
constructor(
private languageService: LanguageService,
private dialog: MatDialog,
private storageService: StorageService
private storageService: StorageService,
@Inject(DOCUMENT) private document: Document
) {
this.tableTemplate = {
selection: true,
Expand Down Expand Up @@ -455,20 +458,18 @@ export class MeasurerComponent implements OnInit, OnDestroy {
* @internal
*/
onDisplayDistance() {
const elements: HTMLCollectionOf<Element> =
this.document.getElementsByClassName(
'igo-map-tooltip-measure-polygone-segments'
);
if (this.displayDistance) {
Array.from(
document.getElementsByClassName(
'igo-map-tooltip-measure-polygone-segments'
)
).map((value: Element) =>
Array.from(elements).map((value: Element) =>
value.classList.remove('igo-map-tooltip-hidden')
);
} else {
Array.from(
document.getElementsByClassName(
'igo-map-tooltip-measure-polygone-segments'
)
).map((value: Element) => value.classList.add('igo-map-tooltip-hidden'));
Array.from(elements).map((value: Element) =>
value.classList.add('igo-map-tooltip-hidden')
);
}
}

Expand All @@ -477,16 +478,19 @@ export class MeasurerComponent implements OnInit, OnDestroy {
* @internal
*/
onDisplayLines() {
if (this.displayLines) {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure-line-segments')
).map((value: Element) =>
value.classList.remove('igo-map-tooltip-hidden')
const elements: HTMLCollectionOf<Element> =
this.document.getElementsByClassName(
'igo-map-tooltip-measure-line-segments'
);

if (this.displayLines) {
Array.from(elements).map((value: Element) => {
value.classList.remove('igo-map-tooltip-hidden');
});
} else {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure-line-segments')
).map((value: Element) => value.classList.add('igo-map-tooltip-hidden'));
Array.from(elements).map((value: Element) => {
value.classList.add('igo-map-tooltip-hidden');
});
}
}

Expand All @@ -495,16 +499,17 @@ export class MeasurerComponent implements OnInit, OnDestroy {
* @internal
*/
onDisplayAreas() {
const elements: HTMLCollectionOf<Element> =
this.document.getElementsByClassName('igo-map-tooltip-measure-area');

if (this.displayAreas) {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure-area')
).map((value: Element) =>
Array.from(elements).map((value: Element) =>
value.classList.remove('igo-map-tooltip-hidden')
);
} else {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure-area')
).map((value: Element) => value.classList.add('igo-map-tooltip-hidden'));
Array.from(elements).map((value: Element) =>
value.classList.add('igo-map-tooltip-hidden')
);
}
}

Expand All @@ -514,11 +519,7 @@ export class MeasurerComponent implements OnInit, OnDestroy {
*/
onLengthUnitChange(unit: MeasureLengthUnit) {
this.activeLengthUnit = unit;
this.table.refresh();
this.updateTooltipsOfOlSource(this.store.source.ol);
if (this.activeOlGeometry !== undefined) {
this.updateTooltipsOfOlGeometry(this.activeOlGeometry);
}
this.refreshTableAndTooltip();
}

/**
Expand All @@ -527,7 +528,12 @@ export class MeasurerComponent implements OnInit, OnDestroy {
*/
onAreaUnitChange(unit: MeasureAreaUnit) {
this.activeAreaUnit = unit;
this.table.refresh();
alecarn marked this conversation as resolved.
Show resolved Hide resolved
this.refreshTableAndTooltip();
}

private refreshTableAndTooltip(): void {
this.store.stateView.clear();

this.updateTooltipsOfOlSource(this.store.source.ol);
if (this.activeOlGeometry !== undefined) {
this.updateTooltipsOfOlGeometry(this.activeOlGeometry);
Expand Down Expand Up @@ -634,16 +640,15 @@ export class MeasurerComponent implements OnInit, OnDestroy {
tryBindStoreLayer(store, layer);
store.layer.visible = true;
layer.visible$.subscribe((visible) => {
const elements: HTMLCollectionOf<Element> =
this.document.getElementsByClassName('igo-map-tooltip-measure');

if (visible) {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure')
).map((value: Element) =>
Array.from(elements).map((value: Element) =>
value.classList.remove('igo-map-tooltip-measure-by-display')
);
} else {
Array.from(
document.getElementsByClassName('igo-map-tooltip-measure')
).map((value: Element) =>
Array.from(elements).map((value: Element) =>
value.classList.add('igo-map-tooltip-measure-by-display')
);
}
Expand All @@ -666,6 +671,8 @@ export class MeasurerComponent implements OnInit, OnDestroy {
const olGeometry = localFeature.getGeometry() as any;
this.updateMeasureOfOlGeometry(olGeometry, localFeature.get('measure'));
this.onDisplayDistance();
this.onDisplayLines();
this.onDisplayAreas();
}
);

Expand Down