Commit 2e6b16e8 authored by Yannick Lehnhausen's avatar Yannick Lehnhausen

Merge branch '137-open-building-view-when-searched-poi-is-inside-a-building' into 'develop'

Resolve "Open building view when searched POI is inside a building"

Closes #137

See merge request !122
parents 30a26e3a 9e197730
Pipeline #29980 failed with stage
in 7 minutes and 9 seconds
......@@ -36,8 +36,8 @@
</span>
</button>
</div>
<div class="col" *ngIf="this.searchToggled" style="display:inline;">
<input type="text" placeholder="Search POI" (keypress) = "this.searchPoi($event)" />
<div class="col" *ngIf="this.mapRendererService.searchToggled" style="display:inline;">
<input type="text" autofocus placeholder="Search POI" (keypress) = "this.searchPoi($event)" />
</div>
<div class="col" *ngIf="this.mapRendererService.isBuildingClicked()">
<button class="btn btn-outline-primary btn-sm"
......
......@@ -32,7 +32,6 @@ export class MapViewComponent implements AfterViewInit, OnDestroy {
end: NavigationPoint | null;
routingState: RoutingState;
buildingEnteredOrLeftSubscription: Subscription;
searchToggled: boolean;
searchterm: string;
constructor(public mapRendererService: MapRendererService,
......@@ -41,7 +40,6 @@ export class MapViewComponent implements AfterViewInit, OnDestroy {
public routeService: RouteService) {
this.route = null;
this.routingState = RoutingState.NotStarted;
this.searchToggled = false;
this.searchterm = null;
this.buildingEnteredOrLeftSubscription = this.mapRendererService.buildingEnteredOrLeft.subscribe(() => {
......@@ -71,6 +69,7 @@ export class MapViewComponent implements AfterViewInit, OnDestroy {
leaveBuilding(): void {
this.mapRendererService.leaveBuilding();
this.rerenderRoute();
this.mapRendererService.searchToggled = false;
}
refresh(): void {
......@@ -173,8 +172,8 @@ export class MapViewComponent implements AfterViewInit, OnDestroy {
}
toggleSearch(): void {
this.searchToggled = !this.searchToggled;
if (this.searchToggled === false) {
this.mapRendererService.searchToggled = !this.mapRendererService.searchToggled;
if (this.mapRendererService.searchToggled === false) {
this.mapRendererService.drawPois();
}
}
......
......@@ -46,6 +46,7 @@ export class MapRendererService {
public poiCut = false;
public selectedID = '';
public error: string = '';
public searchToggled: boolean = false;
private polygons: Polygon[] = [];
private polygonLayers: L.Polygon[] = [];
private map: L.Map;
......@@ -235,6 +236,7 @@ export class MapRendererService {
if (this.isBuildingClicked()) {
this.drawBuildings();
}
this.searchToggled = false;
this.buildingEnteredOrLeft.emit();
}
......@@ -306,17 +308,27 @@ export class MapRendererService {
}
searchPoi(searchterm: string) {
let searchedPoiPos: L.Marker = null;
let searchedPoi: PoiModel = null;
this.removePois();
this.poiMarkersPositions.forEach((poiMarker) => {
if (poiMarker[1].getName().toLowerCase().includes(searchterm.toLowerCase()) ||
poiMarker[1].getDescription().toLowerCase().includes(searchterm.toLowerCase())) {
if (poiMarker[1].levels.length <= 0) {
this.leaveBuilding(poiMarker[1].getID());
} else {
searchedPoiPos = poiMarker[0];
searchedPoi = poiMarker[1];
}
this.drawPois(poiMarker[1].getID());
this.map.setView(poiMarker[0].getLatLng(), startZoomView);
}
});
this.polygons.forEach((polygon) => {
if (this.isMarkerInsidePolygon(searchedPoiPos, polygon)) {
this.enterBuilding(polygon.building, searchedPoi.levels[0]);
}
});
}
private isMarkerInsidePolygon(marker: L.Marker, polygon: Polygon) {
......@@ -505,9 +517,13 @@ export class MapRendererService {
}
}
private enterBuilding(buildingModel: BuildingModel): void {
private enterBuilding(buildingModel: BuildingModel, level?: number): void {
this.selectedBuilding = buildingModel;
this.selectedLevel = buildingModel.levels[0];
if (level) {
this.selectedLevel = buildingModel.levels[level];
} else {
this.selectedLevel = buildingModel.levels[0];
}
this.map.setMinZoom(minZoomSelected);
this.map.setView(this.getSelectedBuildingCenter(), startZoomSelected);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment