-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathhtml-info-window.ts
69 lines (58 loc) · 1.52 KB
/
html-info-window.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
66
67
68
69
import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
Marker,
HtmlInfoWindow
} from '@ionic-native/google-maps';
/**
* Generated class for the HtmlInfoWindowPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-html-info-window',
templateUrl: 'html-info-window.html',
})
export class HtmlInfoWindowPage {
map: GoogleMap;
constructor() {
}
ionViewDidLoad() {
console.log('ionViewDidLoad HtmlInfoWindowPage');
this.loadMap();
}
loadMap() {
this.map = GoogleMaps.create('map_canvas', {
camera: {
target: {lat: 35.685208, lng: -121.168225},
zoom: 5
}
});
let htmlInfoWindow = new HtmlInfoWindow();
let frame: HTMLElement = document.createElement('div');
frame.innerHTML = [
'<h3>Hearst Castle</h3>',
'<img src="assets/imgs/hearst_castle.jpg">'
].join("");
frame.getElementsByTagName("img")[0].addEventListener("click", () => {
htmlInfoWindow.setBackgroundColor('red');
});
htmlInfoWindow.setContent(frame, {
width: "280px",
height: "330px"
});
let marker: Marker = this.map.addMarkerSync({
position: {lat: 35.685208, lng: -121.168225},
draggable: true,
disableAutoPan: true
});
marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(() => {
htmlInfoWindow.open(marker);
});
}
}