/
home.ts
65 lines (51 loc) · 1.68 KB
/
home.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {Component, NgZone} from "@angular/core";
import {NavController, Platform} from 'ionic-angular';
import {GoogleMap, GoogleMapsEvent, GoogleMapsLatLng, GoogleMapsMarkerOptions} from 'ionic-native';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
//const mapConfig: any;
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
private map: GoogleMap;
constructor(private _navController: NavController,
private platform: Platform,
private _zone: NgZone) {
this.platform.ready().then(() => this.onPlatformReady());
}
private onPlatformReady(): void {
}
ngAfterViewInit() {
GoogleMap.isAvailable().then(() => {
this.map = new GoogleMap('map_canvas');
// this.map.on(GoogleMapsEvent.MAP_READY).subscribe(
// () => this.onMapReady(),
// () => alert("Error: onMapReady")
// );
// this.map.on(GoogleMapsEvent.MAP_READY).subscribe(
// (data: any) => {
// alert("GoogleMap.onMapReady(): ");
// },
// () => alert("Error: GoogleMapsEvent.MAP_READY")
// );
this.map.one(GoogleMapsEvent.MAP_READY).then((data: any) => {
alert("GoogleMap.onMapReady(): " + JSON.stringify(data));
this._zone.run(() => {
let myPosition = new GoogleMapsLatLng(38.9072, -77.0369);
console.log("My position is", myPosition);
this.map.animateCamera({ target: myPosition, zoom: 10 });
});
});
});
}
private onMapReady(): void {
alert('Map ready');
//this.map.setOptions(mapConfig);
}
/*
pushPage(){
this._navController.push(SomeImportedPage, { userId: "12345"});
}
*/
}