Skip to content

Commit

Permalink
Step 17.9: Add maps logic to the component
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Nov 27, 2016
1 parent d353c89 commit 5c125ba
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client/imports/app/parties/party-details.component.ts
Expand Up @@ -5,6 +5,7 @@ import { Subscription } from 'rxjs/Subscription';
import { Meteor } from 'meteor/meteor';
import { MeteorObservable } from 'meteor-rxjs';
import { InjectUser } from "angular2-meteor-accounts-ui";
import { MouseEvent } from "angular2-google-maps/core";

import 'rxjs/add/operator/map';

Expand All @@ -28,6 +29,9 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
users: Observable<User>;
uninvitedSub: Subscription;
user: Meteor.User;
// Default center Palo Alto coordinates.
centerLat: number = 37.4292;
centerLng: number = -122.1381;

constructor(
private route: ActivatedRoute
Expand Down Expand Up @@ -121,6 +125,20 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
return false;
}


get lat(): number {
return this.party && this.party.location.lat;
}

get lng(): number {
return this.party && this.party.location.lng;
}

mapClicked($event: MouseEvent) {
this.party.location.lat = $event.coords.lat;
this.party.location.lng = $event.coords.lng;
}

ngOnDestroy() {
this.paramsSub.unsubscribe();
this.partySub.unsubscribe();
Expand Down

0 comments on commit 5c125ba

Please sign in to comment.