Skip to content

Commit

Permalink
added onbegluurd checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhoek committed May 7, 2018
1 parent 69fa86f commit a1c204b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/app/map/from-to/from-to.component.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.from-to-container {
position: absolute;
height: 52px;
height: 80px;
width: 380px;
background: #f6be0e;
z-index: 500;
Expand Down Expand Up @@ -96,3 +96,14 @@ button:active {
background: #fff;
}

.checkbox-container {
z-index: 500;
position: absolute;
top: 75px;
left: 5px;
}

.checkbox {
width: 20px;
height: 20px;
}
4 changes: 4 additions & 0 deletions src/app/map/from-to/from-to.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
<div id="from-to-search">
<button (click)="findRoute()" type="button" name="button">zoek</button>
</div>

<div class="checkbox-container">
<input type="checkbox" class="checkbox" [(ngModel)]="onbegluurd" name="gluren" (change)="setOnbegluurd($event)" value="false">Ik wil onbegluurd fietsen.
</div>
</div>
8 changes: 7 additions & 1 deletion src/app/map/from-to/from-to.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppHttpService } from '../../shared/app-http.service';
import { Subject } from 'rxjs/Subject';
import "rxjs/add/operator/map";
import "rxjs/add/operator/debounceTime";
import { RoutingService } from '../../shared/routing.service';
@Component({
selector: 'app-from-to',
templateUrl: './from-to.component.html',
Expand All @@ -16,7 +17,8 @@ export class FromToComponent implements OnInit {
public naarSuggests = [];
public vanLoc = [];
public naarLoc = [];
constructor(private http: AppHttpService) {
public onbegluurd = false;
constructor(private http: AppHttpService, private routingService: RoutingService) {

}
ngOnInit() {
Expand All @@ -37,6 +39,10 @@ export class FromToComponent implements OnInit {
this.naarSubject.next(event);
}

public setOnbegluurd(event: Event) {
this.routingService.setBegluurdStatus(this.onbegluurd);
}

public getVanSuggest(van) {
const suggestUrl = 'https://geodata.nationaalgeoregister.nl/locatieserver/v3/suggest?q='
this.http.get(suggestUrl+van).then(r=>{
Expand Down
16 changes: 14 additions & 2 deletions src/app/shared/routing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class RoutingService {
private googleProxy = 'http://localhost:3000/direction-proxy?';
private googleUrlEndpoint = 'https://maps.googleapis.com/maps/api/directions/json?';
private googleApiKey = 'AIzaSyDWy6wP5gJzKJ0xc7UV7j1gUJ2cv4NZv20';
private onbegluurd = false;

constructor(private http: AppHttpService) {

Expand All @@ -25,16 +26,27 @@ export class RoutingService {
// });
// }

public getNonCameraRoute(origin, destination) {
public setBegluurdStatus(bool: boolean) {
this.onbegluurd = bool;
}

private getNonCameraRoute(origin, destination) {
const body = {"privacy": true, "start":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[5.087872,52.072859]}},"end":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[5.119543,52.074152]}}};
return this.http.post('http://service.geoloep.nl/routing/api/route/', body);
}

public getCameraRoute(origin, destination) {
private getCameraRoute(origin, destination) {
const body = {"privacy": false,"start":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[5.087872,52.072859]}},"end":{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[5.119543,52.074152]}}};
return this.http.post('http://service.geoloep.nl/routing/api/route/', body);
}

public getRoute(origin, destination) {
if (this.onbegluurd) {
return this.getNonCameraRoute(origin, destination);
} else {
return this.getCameraRoute(origin, destination);
}
}
// public createRouteLinestring(directions) {
// const geometry = {
// type: 'LineString',
Expand Down

0 comments on commit a1c204b

Please sign in to comment.