-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGWindow.js
73 lines (59 loc) · 2.06 KB
/
GWindow.js
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
70
71
72
73
function GWindow(map, options) {
if(typeof options === "undefined") options = {};
options.offsetX = options.offsetX || 0;
options.offsetY = options.offsetY || 0;
this.options_ = options;
this.setMap(map);
var div = document.createElement("DIV"),
self = this;
div.style.cssText = "position:absolute;visibility:hidden;";
div.setAttribute("class", "g-window");
this.div_ = div;
this.findByClass_ = function(tag, cname) {
anchors = this.div_.getElementsByTagName(tag);
for(var i = 0; i < anchors.length; i++) {
if(anchors[i].className === cname) {
return anchors[i];
}
}
}
this.setClose_ = function() {
this.close_ = this.findByClass_("a", "close");
if(typeof this.close_ != "undefined") {
this.close_.onclick = function() {
self.remove();
}
}
}
this.setContent = function(content) {
this.content_ = content || this.content_;
if(typeof this.div_ != "undefined") {
this.div_.innerHTML = this.content_;
this.setClose_();
}
}
}
GWindow.prototype = new google.maps.OverlayView;
GWindow.prototype.draw = function() {
this.projection_ = this.getProjection();
if(typeof this.latLong_ != "undefined") {
var point = this.projection_.fromLatLngToDivPixel(this.latLong_);
this.div_.style.left = (point.x + this.options_.offsetX) + "px";
this.div_.style.top = (point.y + this.options_.offsetY) + "px";
}
}
GWindow.prototype.onRemove = function() {
this.windowContent_.style.visibility = "hidden";
this.div_.style.visibility = "hidden";
}
GWindow.prototype.open = function(latLong) {
this.latLong_ = latLong;
var div = this.div_;
div.style.visibility = "visible";
this.getPanes().floatPane.appendChild(this.div_);
this.draw();
}
GWindow.prototype.remove = function() {
this.div_.parentNode.removeChild(this.div_);
this.div_.style.visibility = "hidden";
}