Skip to content
Snippets Groups Projects
Commit b17060bd authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix(orientation): distance display when no position sharing

parent fe91b46d
No related branches found
No related tags found
4 merge requests!418V2.1.0,!400V2.0,!395Resolve "Affichage distance lors de l'orientation",!230V2.0
...@@ -49,6 +49,7 @@ export class CartoComponent implements OnInit { ...@@ -49,6 +49,7 @@ export class CartoComponent implements OnInit {
// Set user location if provided // Set user location if provided
if (this.userLatitude && this.userLongitude) { if (this.userLatitude && this.userLongitude) {
this.userLocate = [this.userLongitude, this.userLatitude]; this.userLocate = [this.userLongitude, this.userLatitude];
this.getAddress(this.userLongitude, this.userLatitude);
} }
if (navigator.geolocation) { if (navigator.geolocation) {
this.getLocation(this.filters); this.getLocation(this.filters);
...@@ -74,7 +75,7 @@ export class CartoComponent implements OnInit { ...@@ -74,7 +75,7 @@ export class CartoComponent implements OnInit {
if (this.isLocationRequest(queryString.value)) { if (this.isLocationRequest(queryString.value)) {
this.getCoordByAddress(queryString.value).then((res) => { this.getCoordByAddress(queryString.value).then((res) => {
this.currentLocation = res; this.currentLocation = res;
this.updateStructuresdistance( this.updateStructuresDistance(
this.structures, this.structures,
this.currentLocation.geometry.getLon(), this.currentLocation.geometry.getLon(),
this.currentLocation.geometry.getLat() this.currentLocation.geometry.getLat()
...@@ -83,7 +84,7 @@ export class CartoComponent implements OnInit { ...@@ -83,7 +84,7 @@ export class CartoComponent implements OnInit {
} else { } else {
this.structureService.getStructures(filters).subscribe((structures) => { this.structureService.getStructures(filters).subscribe((structures) => {
if (structures) { if (structures) {
this.updateStructuresdistance(structures, this.userLongitude, this.userLatitude, false); this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false);
} else { } else {
this.structures = null; this.structures = null;
} }
...@@ -93,7 +94,7 @@ export class CartoComponent implements OnInit { ...@@ -93,7 +94,7 @@ export class CartoComponent implements OnInit {
this.searchedValue = null; this.searchedValue = null;
this.structureService.getStructures(filters).subscribe((structures) => { this.structureService.getStructures(filters).subscribe((structures) => {
if (structures) { if (structures) {
this.updateStructuresdistance(structures, this.userLongitude, this.userLatitude); this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude);
} else { } else {
this.structures = null; this.structures = null;
} }
...@@ -111,10 +112,10 @@ export class CartoComponent implements OnInit { ...@@ -111,10 +112,10 @@ export class CartoComponent implements OnInit {
* Update structure distance according to user actual position. * Update structure distance according to user actual position.
* @param structures structures data to update * @param structures structures data to update
* @param lon user longitude * @param lon user longitude
* @param lat user latitde * @param lat user latitude
* @param sortByDistance if set to `true`, structures data is sort by distance. Default value is `true` * @param sortByDistance if set to `true`, structures data is sort by distance. Default value is `true`
*/ */
private updateStructuresdistance( private updateStructuresDistance(
structures: Structure[], structures: Structure[],
lon: number, lon: number,
lat: number, lat: number,
...@@ -122,11 +123,11 @@ export class CartoComponent implements OnInit { ...@@ -122,11 +123,11 @@ export class CartoComponent implements OnInit {
): void { ): void {
Promise.all( Promise.all(
structures.map(async (structure) => { structures.map(async (structure) => {
if (this.geolocation) { if (lon && lat) {
structure = this.getStructurePosition(structure, lon, lat); structure = this.getStructurePosition(structure, lon, lat);
if (this.isAdmin) { }
structure.isClaimed = await this.isClaimed(structure).toPromise(); if (this.isAdmin) {
} structure.isClaimed = await this.isClaimed(structure).toPromise();
} }
return structure; return structure;
}) })
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<span class="typeStructure" [ngClass]="{ typeStructureOrientation: isOrientation }">{{ <span class="typeStructure" [ngClass]="{ typeStructureOrientation: isOrientation }">{{
structure.getLabelTypeStructure() structure.getLabelTypeStructure()
}}</span> }}</span>
<span *ngIf="isOrientation" class="distance"> <span *ngIf="isOrientation && structure.distance" class="distance">
{{ this.formatDistance() }} {{ this.formatDistance() }}
</span> </span>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment