diff --git a/src/app/app.component.css b/src/app/app.component.css index d28069b..5073e54 100644 --- a/src/app/app.component.css +++ b/src/app/app.component.css @@ -1,10 +1,9 @@ header{ - background-color: rgb(37, 37, 37); - height: 50px; - font-size: 15pt; - color:white; - font-weight: bold; - + background-color: rgb(37, 37, 37); + height: 50px; + font-size: 15pt; + color:white; + font-weight: bold; } header p{ @@ -18,3 +17,42 @@ header p{ width: 100%; height: 100%; } + +.osrm-route-container{ + position: absolute; + right: 0; + width:300px; + margin-top: 50px; + background-color: rgba(27, 27, 27, 0.801); + top:0; + bottom: 0; + color: white; +} + +.osrm-route-container h4{ + text-align: center; + line-height: 30px; + letter-spacing: 1px; + padding-top: 0px; + margin-top: 2px; +} + +.route-list{ + width: 100%; + display: block; + font-weight: bold; + text-align: left; +} + +.route-list div{ + width: 100%; + display: block; + border-top: 1px solid rgba(255, 255, 255, 0.418); + padding-top: 5px; + padding-bottom: 5px; +} + +.route-list div p{ + display: inline-block; + padding-left: 40px; +} diff --git a/src/app/app.component.html b/src/app/app.component.html index b78cf35..ae52aa1 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -3,4 +3,15 @@

{{title}}

-
\ No newline at end of file +
+ +
+

Your Route Steps

+ +
+
+

{{step.maneuver?.type }} {{step.maneuver?.modifier }}

+
+
+
+ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1b736c5..e433691 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -9,7 +9,7 @@ import ZoomToExtent from 'ol/control/ZoomToExtent'; import VectorLayer from 'ol/layer/Vector'; import VectorSource from 'ol/source/Vector'; import LineString from 'ol/geom/LineString'; -import { Osrm } from './interfaces/osrm'; +import { Osrm, OsrmStep } from './interfaces/osrm'; import { Feature } from 'ol'; import Geometry from 'ol/geom/Geometry'; @@ -22,6 +22,7 @@ import Geometry from 'ol/geom/Geometry'; export class AppComponent implements AfterViewInit { title = "Street Map"; map: Map; + routeSteps: Array = [] constructor() { } @@ -66,8 +67,11 @@ export class AppComponent implements AfterViewInit { const lineString: LineString = new LineString(f_coordinates); const feature: Feature = new Feature({ geometry: lineString }); const vectorSource = new VectorSource({ features: [ feature ]}); - console.log(feature.getGeometry()); - const vectorLayer = new VectorLayer({ source: vectorSource }); + + const vectorLayer = new VectorLayer({ + + source: vectorSource, + }); this.map.addLayer(vectorLayer); // this.features = new GeoJSON().readFeatures(new openLayersGeoJSON()) @@ -83,5 +87,14 @@ export class AppComponent implements AfterViewInit { this.map.addLayer(this.vectorLayer);*/ } + + updateSidebar(osrm: Osrm): void{ + console.log("updateSidebar") + if(osrm.routes[0].legs[0].steps){ + this.routeSteps = osrm.routes[0].legs[0].steps; + } + console.log(this.routeSteps) + } + } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 50a8305..6ce9c83 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,13 +3,11 @@ import { BrowserModule } from '@angular/platform-browser'; import {HttpClientModule} from '@angular/common/http'; import { AppComponent } from './app.component'; import { SearchComponent } from './search/search.component'; -import { OsrmComponent } from './osrm/osrm.component'; @NgModule({ declarations: [ AppComponent, SearchComponent, - OsrmComponent, ], imports: [ BrowserModule, diff --git a/src/app/interfaces/osrm.ts b/src/app/interfaces/osrm.ts index 6ed2f5b..7fd8114 100644 --- a/src/app/interfaces/osrm.ts +++ b/src/app/interfaces/osrm.ts @@ -1,25 +1,47 @@ interface OsrmWaypoint{ - hint?: string; - distance?: number; - location?: Array; - name?: string; + hint?: string; + distance?: number; + location?: Array; + name?: string; +} + +interface OsrmManeuver{ + type?: string; + modifier?: string; +} + +export interface OsrmStep{ + driving_side?: string; + duration?: number; + distance?: number; + name?: string; + maneuver?: OsrmManeuver; +} + +interface OsrmLeg{ +steps?: Array; +weight?: number; +distance?: number; +summary?: string; +duration?: number; } interface OsrmGeometry{ - type: GeometryType; - coordinates?: Array>; + type: GeometryType; + coordinates?: Array>; } enum GeometryType { - LINE_STRING = "LineString" + LINE_STRING = "LineString" } interface OsrmRoute{ - geometry: OsrmGeometry; + legs: Array; + geometry: OsrmGeometry; } export interface Osrm{ - code?: string; - waypoints?: Array; - routes: Array; -} \ No newline at end of file + code?: string; + waypoints?: Array; + routes: Array; +} diff --git a/src/app/osrm/osrm.component.css b/src/app/osrm/osrm.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/osrm/osrm.component.html b/src/app/osrm/osrm.component.html deleted file mode 100644 index 0978384..0000000 --- a/src/app/osrm/osrm.component.html +++ /dev/null @@ -1 +0,0 @@ -

osrm works!

diff --git a/src/app/osrm/osrm.component.spec.ts b/src/app/osrm/osrm.component.spec.ts deleted file mode 100644 index b4a0751..0000000 --- a/src/app/osrm/osrm.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { OsrmComponent } from './osrm.component'; - -describe('OsrmComponent', () => { - let component: OsrmComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ OsrmComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(OsrmComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/osrm/osrm.component.ts b/src/app/osrm/osrm.component.ts deleted file mode 100644 index 030faeb..0000000 --- a/src/app/osrm/osrm.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-osrm', - templateUrl: './osrm.component.html', - styleUrls: ['./osrm.component.css'] -}) - -export class OsrmComponent implements OnInit { - - constructor() { } - - - ngOnInit(): void { - } -} diff --git a/src/app/search/search.component.ts b/src/app/search/search.component.ts index eaef405..d5801f4 100644 --- a/src/app/search/search.component.ts +++ b/src/app/search/search.component.ts @@ -6,6 +6,8 @@ import { PhotonService } from '../photon.service'; import { OsrmService } from '../osrm.service'; import { Osrm } from '../interfaces/osrm'; import { AppComponent } from '../app.component'; + + @Component({ selector: 'app-search', templateUrl: './search.component.html', @@ -36,7 +38,7 @@ export class SearchComponent{ private nominatimService: NominatimService, private photonService: PhotonService, private osrmService: OsrmService, - private appComponent: AppComponent + private appComponent: AppComponent, ) { } selectPhoton(isFrom: boolean, p: Photon): void{ @@ -106,10 +108,9 @@ export class SearchComponent{ } getRoute(): void{ - this.osrmService.sendQueryRequest(this.longFrom, this.latFrom, this.longTo, this.latTo) .subscribe((response: Osrm) => { - console.log(response); + this.appComponent.updateSidebar(response); this.appComponent.drawPath(response); } ); diff --git a/src/styles.css b/src/styles.css index c5a586b..6b98590 100644 --- a/src/styles.css +++ b/src/styles.css @@ -14,9 +14,10 @@ body { top:0; bottom:0; right:0; - left:0; + left:0; + overflow: hidden; } button{ outline: 0; -} \ No newline at end of file +}