/** * square overlay : popup on top of the markers * * @param center * @param width * @param height * @param color * @param storename * @param storedescription * @constructor */ function marker(center, data, onclick) { this._center = center; this._width = 186; this._height = 45; this._data = data; this._drew = false; } // inherit baidu map's overlay marker.prototype = new bmap.overlay(); marker.prototype.initialize = function (map) { this._map = map; var thisoverlay = this; var div = document.createelement("div"); div.classname += ' marker-overlay'; if (this._data.bgcolor) { div.style.backgroundcolor = this._data.bgcolor; div.style.bordercolor = this._data.bgcolor; } if (this._data.fgcolor) div.style.color = this._data.fgcolor; var markername = document.createelement("span"); markername.classname += ' marker-name'; markername.innerhtml = this._data.name; var markerdescription = document.createelement("span"); markerdescription.classname += ' marker-description'; markerdescription.innerhtml = this._data.description; div.appendchild(markername); div.appendchild(markerdescription); map.getpanes().markerpane.appendchild(div); this._div = div; jquery(div).click(function () { thisoverlay.toggle(); }); console.log(jquery(this._data.marker)); this._data.marker.addeventlistener('click', function () { thisoverlay.toggle(); }); return div; } marker.prototype.draw = function () { var position = this._map.pointtooverlaypixel(this._center); this._div.style.left = position.x - this._width / 2 - 3 + "px"; this._div.style.top = position.y - this._height + "px"; if (!this._drew) { if (this._data.ishidden) { this._data.marker.show(); this.hide(); } else { this.show() this._data.marker.hide(); } this._drew = true; } } marker.prototype.show = function () { if (this._div) { this._div.style.display = ""; this._data.marker.hide(); } } marker.prototype.hide = function () { if (this._div) { this._div.style.display = "none"; this._data.marker.show(); } } marker.prototype.toggle = function () { if (this._div) { if (this._div.style.display == "") { this.hide(); } else { this.show(); } } }