Add : setBackgroundColor() method to HtmlInfoWindow
MODIFY
www/HtmlInfoWindow.js
www/HtmlInfoWindow.js
@@ -16,9 +16,9 @@ var HTMLInfoWindow = function() {
frame.style.display = "inline-block";
self.set("frame", frame);
- var content = document.createElement("div");
- content.style.display = "inline-block";
- content.style.padding = "5px";
+ var contentBox = document.createElement("div");
+ contentBox.style.display = "inline-block";
+ contentBox.style.padding = "5px";
var contentFrame = document.createElement("div");
contentFrame.style.display = "block";
@@ -28,7 +28,7 @@ var HTMLInfoWindow = function() {
contentFrame.style.left = "0px";
contentFrame.style.right = "0px";
frame.appendChild(contentFrame);
- contentFrame.appendChild(content);
+ contentFrame.appendChild(contentBox);
var tailFrame = document.createElement("div");
tailFrame.style.position = "relative";
@@ -70,14 +70,12 @@ var HTMLInfoWindow = function() {
var contentFrame = frame.firstChild;
var contentBox = contentFrame.firstChild;
- // Display the title property
- // (ignore the snippet propert)
- var title = marker.get("title");
- if (typeof title === "string") {
+ var content = self.get("content");
+ if (typeof content === "string") {
contentBox.style.whiteSpace="nowrap";
- contentBox.innerHTML = title;
+ contentBox.innerHTML = content;
} else {
- contentBox.appendChild(title);
+ contentBox.appendChild(content);
}
// Insert the contents to this HTMLInfoWindow
@@ -86,9 +84,9 @@ var HTMLInfoWindow = function() {
}
// Adjust the HTMLInfoWindow size
- var contentsWidth = contentBox.clientWidth;
+ var contentsWidth = contentBox.offsetWidth;
self.set("contentsWidth", contentsWidth);
- var contentsHeight = contentBox.clientHeight;
+ var contentsHeight = contentBox.offsetHeight;
self.set("contentsHeight", contentsHeight );
contentFrame.style.width = contentsWidth + "px";
contentFrame.style.height = contentsHeight + "px";
@@ -177,8 +175,12 @@ HTMLInfoWindow.prototype.close = function(marker) {
// Remove the contents from this HTMLInfoWindow
var contentFrame = frame.firstChild;
- var content = contentFrame.firstChild;
- content.innerHTML = "";
+ var contentBox = contentFrame.firstChild;
+ contentBox.innerHTML = "";
+};
+
+HTMLInfoWindow.prototype.setContent = function(content) {
+ this.set("content", content);
};
HTMLInfoWindow.prototype.open = function(marker) {
@@ -186,6 +188,8 @@ HTMLInfoWindow.prototype.open = function(marker) {
return;
}
var map = marker.getMap();
+ var self = this;
+
map.bindTo("infoPosition", this);
marker.bindTo("HTMLInfoWindowAnchor", this);
marker.bindTo("icon", this);
@@ -193,4 +197,10 @@ HTMLInfoWindow.prototype.open = function(marker) {
this.trigger("HTMLInfoWindowAnchor_changed");
};
+HTMLInfoWindow.prototype.setBackgroundColor = function(backgroundColor) {
+ this.get("frame").children[0].style.backgroundColor = backgroundColor;
+ this.get("frame").children[1].children[0].style.borderColor = backgroundColor + " transparent transparent";
+ this.get("frame").children[1].children[1].style.borderColor = backgroundColor + " transparent transparent";
+};
+
module.exports = HTMLInfoWindow;

Add : setBackgroundColor() method to HtmlInfoWindow