Skip to content

Commit d1c91b2

Browse files
committed
Merge branch 'CreateTripPlannerScreen' into RefactorTripPlanner
2 parents c63042f + acfe354 commit d1c91b2

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"@angular/cli": "1.1.1",
3535
"@angular/compiler-cli": "^4.0.0",
3636
"@angular/language-service": "^4.0.0",
37-
"@types/googlemaps": "^3.29.2",
3837
"@types/jasmine": "2.5.45",
3938
"@types/node": "~6.0.60",
4039
"codelyzer": "~3.0.1",

src/app/common/states/gmaps.service.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export class GMapsDirectionsService {
2222

2323
updateDirections() {
2424
this.gmapsApi.getNativeMap().then(map => {
25-
//Prepare Map and Display Settings
25+
// Prepare Map and Display Settings
2626
if (!this.originPlaceId || !this.destinationPlaceId) {
2727
return;
2828
}
2929

30-
var directionsService = new google.maps.DirectionsService;
31-
var service = this;
32-
var origin = new google.maps.LatLng({ lat: this.origin.latitude, lng: this.origin.longitude });
33-
var destination = new google.maps.LatLng({ lat: this.destination.latitude, lng: this.destination.longitude });
30+
const directionsService = new google.maps.DirectionsService;
31+
const service = this;
32+
const origin = new google.maps.LatLng({ lat: this.origin.latitude, lng: this.origin.longitude });
33+
const destination = new google.maps.LatLng({ lat: this.destination.latitude, lng: this.destination.longitude });
3434

3535
this.directionsDisplay.setMap(map);
3636
this.directionsDisplay.setOptions({
@@ -41,31 +41,30 @@ export class GMapsDirectionsService {
4141
}
4242
});
4343

44-
//Update Display
44+
// Update Display
4545
this.directionsDisplay.setDirections({ routes: [] });
4646

47-
//Determine Directions
48-
//Request
47+
// Determine Directions
48+
// Request
4949
directionsService.route({
5050
origin: { placeId: this.originPlaceId },
5151
destination: { placeId: this.destinationPlaceId },
5252
avoidHighways: true,
5353
travelMode: google.maps.DirectionsTravelMode.DRIVING
54-
},
55-
//Response
54+
},
55+
// Response
5656
function (response: any, status: any) {
5757
if (status === 'OK') {
5858
service.directionsDisplay.setDirections(response);
5959
map.setZoom(30);
60-
var point = response.routes[0].legs[0];
60+
const point = response.routes[0].legs[0];
6161
service.estimatedTime = point.duration.text;
6262
service.estimatedDistance = point.distance.text;
6363
console.log('Estimated travel time: ' + point.duration.text + ' (' + point.distance.text + ')');
6464
} else {
6565
console.log('Directions request failed due to ' + status);
6666
}
6767
});
68-
6968
});
7069
}
7170

src/app/passengers/components/smart/trip-planner/trip-planner.component.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ export class TripPlannerComponent implements OnInit {
2626
@Input() private initialLat: number;
2727
@Input() private initialLng: number;
2828

29-
@ViewChild("pickupInput")
29+
@ViewChild('pickupInput')
3030
public pickupInputElementRef: ElementRef;
3131

32-
@ViewChild("pickupOutput")
32+
@ViewChild('pickupOutput')
3333
public pickupOutputElementRef: ElementRef;
3434

3535
@ViewChild(GMapsDirectionsService) service: GMapsDirectionsService;
3636

3737
constructor(
38-
private ngZone: NgZone,
39-
private mapsAPILoader: MapsAPILoader,
40-
private gmapsApi: GoogleMapsAPIWrapper,
38+
private ngZone: NgZone,
39+
private mapsAPILoader: MapsAPILoader,
40+
private gmapsApi: GoogleMapsAPIWrapper,
4141
private _elementRef: ElementRef) {
4242
}
4343

@@ -58,25 +58,25 @@ export class TripPlannerComponent implements OnInit {
5858
this.destinationInput = new FormControl();
5959
this.destinationOutput = new FormControl();
6060

61-
//Update Map View
61+
// Update Map View
6262
this.setCurrentPosition();
63-
64-
//Load Autocomplete for Inputs
63+
64+
// Load Autocomplete for Inputs
6565
this.mapsAPILoader.load().then(() => {
66-
let autocompleteInput = new google.maps.places.Autocomplete(this.pickupInputElementRef.nativeElement, {
67-
types: ["address"]
66+
const autocompleteInput = new google.maps.places.Autocomplete(this.pickupInputElementRef.nativeElement, {
67+
types: ['address']
6868
});
6969

70-
let autocompleteOutput = new google.maps.places.Autocomplete(this.pickupOutputElementRef.nativeElement, {
71-
types: ["address"]
70+
const autocompleteOutput = new google.maps.places.Autocomplete(this.pickupOutputElementRef.nativeElement, {
71+
types: ['address']
7272
});
7373
this.setupPlaceChangedListener(autocompleteInput, 'pickup');
7474
this.setupPlaceChangedListener(autocompleteOutput, 'destination');
7575
});
7676
}
7777

7878
setCurrentPosition() {
79-
if ("geolocation" in navigator) {
79+
if ('geolocation' in navigator) {
8080
navigator.geolocation.getCurrentPosition((position) => {
8181
this.latitude = position.coords.latitude;
8282
this.longitude = position.coords.longitude;
@@ -85,9 +85,9 @@ export class TripPlannerComponent implements OnInit {
8585
}
8686

8787
private setupPlaceChangedListener(autocomplete:any, inputType:string) {
88-
autocomplete.addListener("place_changed", () => {
88+
autocomplete.addListener('place_changed', () => {
8989
this.ngZone.run(() => {
90-
let place: google.maps.places.PlaceResult = autocomplete.getPlace();
90+
const place: google.maps.places.PlaceResult = autocomplete.getPlace();
9191
if (place.geometry === undefined) {
9292
return;
9393
}

0 commit comments

Comments
 (0)