﻿function SArea(a, b, c) { this.status_ = 0; this.areaData_ = a; this.id_ = this.areaData_.id; this.map_ = b; this.colors_ = c; this.polygon_ = []; this.iconDefinitions_ = { on: { main: { backgroundColor: "#F68D1E" }, accent: { backgroundColor: "#F68D1E", shadowColor: "#7b460f"} }, off: { main: { backgroundColor: "#5C5C5C" }, accent: { backgroundColor: "#F68D1E", shadowColor: "#7b460f"}} }; this.polygonDefinitions_ = { mouseover: { id: 1, polygons: [{ line: { color: "#ffffff", opacity: 1, weight: 5, doLine: true }, fill: { color: "#000000", opacity: .15, doFill: true} }, { line: { color: this.colors_.color, opacity: 1, weight: 3, doLine: true }, fill: { doFill: false}}] }, on: { id: 2, polygons: [{ line: { color: "#000000", opacity: 1, weight: 5, doLine: false }, fill: { color: "#000000", opacity: .4, doFill: true}}]} }; this.polygon_ = new SPolygon(this.map_, this.areaData_.points, this.areaData_.levels); this.icon_ = new SPlaceIcon(this.areaData_.count, this.areaData_.zipCode, this.areaData_.name, this.iconDefinitions_, new GLatLng(this.areaData_.lat, this.areaData_.lng)); this.map_.addOverlay(this.icon_); this._eventHandlers = []; GEvent.bind(this.icon_, "mouseenter", this, this.iconMouseover); GEvent.bind(this.icon_, "mouseleave", this, this.iconMouseout); GEvent.bind(this.icon_, "click", this, this.iconClick) } function SPolygon(a, b, c) { this.map_ = a; this.points_ = b; this.levels_ = c; this.polygons_ = []; this.added_ = []; this.visible_ = [] } function SPlaceIcon(a, b, c, d, e) { this.centroid_ = e; this.count_ = parseInt(a).format(0, ","); this.areaName_ = c; this.zipCode_ = b; this.iconDefenitions_ = d; this.offset_ = { left: 20, top: 9 }; this.dom_ = { number: null, shadowNumber: null, name: null, color: null, shadowColor: null, status: null, iconDefenition: null} } try { SPlaceIcon.prototype = new GOverlay } catch (e) { } SPlaceIcon.prototype.initialize = function (a) { var b = document.createElement("table"); var c = document.createElement("tbody"); var d = document.createElement("tr"); var e = document.createElement("td"); e.className = "number"; this.dom_.color = e; var f = document.createElement("div"); var g = document.createElement("span"); g.className = "left"; this.dom_.shadowColor = g; var h = document.createTextNode(this.count_); this.dom_.numberShadow = h; g.appendChild(h); f.appendChild(g); g = document.createElement("span"); g.className = "right"; h = document.createTextNode(this.count_); this.dom_.number = h; if (this.count_ > 0) { g.appendChild(h); f.appendChild(g); e.appendChild(f); d.appendChild(e) } e = document.createElement("td"); e.className = "name"; h = document.createTextNode(" " + this.areaName_); g = document.createElement("span"); g.className = "iconAreaName"; g.appendChild(h); h = document.createTextNode(this.zipCode_); var i = document.createElement("span"); i.setAttribute("id", this.zipCode_); i.className = "iconZipCode smaller"; i.appendChild(h); i.appendChild(g); this.dom_.name = h; e.appendChild(i); d.appendChild(e); c.appendChild(d); b.appendChild(c); b.className = "placeIcon2"; b.style.position = "absolute"; this.dom_.status = 0; this.dom_.iconDefenition = this.iconDefenitions_; this.dom_.color.style.backgroundColor = this.iconDefenitions_.off.accent.backgroundColor; this.dom_.shadowColor.style.color = this.iconDefenitions_.off.accent.shadowColor; a.getPane(G_MAP_MARKER_PANE).appendChild(b); this.map_ = a; this.table_ = b; $j(this.table_).bind("mouseenter", { me: this }, function (a) { var b = a.data.me.dom_.name.parentNode.id; if (a.data.me.dom_.status == 0) { $j("#" + b).removeClass("smaller"); $j("#" + b).addClass("bigger"); $j("#" + b + " .iconAreaName").show() } a.data.me.dom_.name.parentNode.style.textDecoration = "underline"; a.data.me.zIndex_ = a.data.me.table_.style.zIndex; a.data.me.table_.style.zIndex = 1e3; GEvent.trigger(a.data.me, "mouseenter") }); $j(this.table_).bind("mouseleave", { me: this }, function (a) { var b = a.data.me.dom_.name.parentNode.id; if (a.data.me.dom_.status == 0) { $j("#" + b).removeClass("bigger"); $j("#" + b).addClass("smaller"); $j("#" + b + " .iconAreaName").hide() } a.data.me.dom_.name.parentNode.style.textDecoration = "none"; a.data.me.table_.style.zIndex = a.data.me.zIndex_; GEvent.trigger(a.data.me, "mouseleave") }); $j(this.table_).bind("click", { me: this }, function (a) { var b = a.data.me.dom_.name.parentNode.id; if (a.data.me.dom_.status != 0) { $j("#" + b).removeClass("selected"); $j("#" + b).removeClass("bigger"); $j("#" + b).addClass("smaller"); $j("#" + b + " .iconAreaName").hide(); a.data.me.dom_.status = 0 } else { $j("#" + b).removeClass("smaller"); $j("#" + b).addClass("selected"); $j("#" + b).addClass("bigger"); $j("#" + b + " .iconAreaName").show(); a.data.me.dom_.status = 1 } GEvent.trigger(a.data.me, "click") }) }; SPlaceIcon.prototype.remove = function () { try { this.table_.parentNode.removeChild(this.table_) } catch (a) { } }; SPlaceIcon.prototype.copy = function () { return new SPlaceIcon(this.count_, this.name_, this.color_, this.shadowColor_, this.centroid_) }; SPlaceIcon.prototype.redraw = function (a) { if (!a) return; var b = this.map_.fromLatLngToDivPixel(this.centroid_); this.table_.style.left = b.x - this.offset_.left + "px"; this.table_.style.top = b.y - this.offset_.top + "px"; var c = GOverlay.getZIndex(this.centroid_.lat()); this.table_.style.zIndex = c }; SPlaceIcon.prototype.show = function () { this.table_.style.visibility = "hidden" }; SPlaceIcon.prototype.hide = function () { this.table_.style.visibility = "visible" }; SPlaceIcon.prototype.on = function () { $j("#" + this.zipCode_).removeClass("smaller"); $j("#" + this.zipCode_).addClass("selected"); $j("#" + this.zipCode_).addClass("bigger"); $j("#" + this.zipCode_ + " .iconAreaName").show(); this.dom_.status = 1 }; SPlaceIcon.prototype.off = function () { $j("#" + this.zipCode_).removeClass("selected"); $j("#" + this.zipCode_).removeClass("bigger"); $j("#" + this.zipCode_).addClass("smaller"); $j("#" + this.zipCode_ + " .iconAreaName").hide(); this.dom_.status = 0 }; SPlaceIcon.prototype.edit = function (a, b, c, d, e) { if (a != undefined) { this.dom_.number.nodeValue = a; this.dom_.numberShadow.nodeValue = a } if (b) this.dom_.name.nodeValue = b; if (c) { this.color_ = c; this.dom_.color.style.backgroundColor = this.color_ } if (d) { this.shadowColor_ = d; this.dom_.shadowColor.style.color = this.shadowColor_ } if (e) this.move(e) }; SPlaceIcon.prototype.move = function (a) { this.centroid_ = a; this.redraw(true) }; SPlaceIcon.prototype.getLatLng = function () { return this.centroid_ }; SPlaceIcon.prototype.setLatLng = function (a) { this.move(a) }; SPolygon.prototype = { makePolygons: function (a) { var b = this.points_.split("$"); var c = this.levels_.split("$"); var d = {}; for (var e = 0; e < b.length; e++) { for (var f = 0; f < a.length; f++) { if (!d[f]) d[f] = []; d[f].push({ points: b[e], levels: c[e], color: a[f].line.color, weight: a[f].line.weight, opacity: a[f].line.opacity, numLevels: 18, zoomFactor: 2 }) } } var g = []; for (var f = 0; f < a.length; f++) { var h = new GPolygon.fromEncoded({ polylines: d[f], fill: a[f].fill.doFill, color: a[f].fill.color || "#000000", opacity: a[f].fill.opacity || 0, outline: a[f].line.doLine }); g.push(h) } return g }, add: function (a) { if (!this.polygons_[a.id]) { this.polygons_[a.id] = this.makePolygons(a.polygons) } if (!this.added_[a.id]) { var b = this.map_; for (var c = 0; c < this.polygons_[a.id].length; c++) { GEvent.addListener(this.polygons_[a.id][c], "click", function (a) { GEvent.trigger(b, "click", this, a) }); this.map_.addOverlay(this.polygons_[a.id][c]) } this.added_[a.id] = true; this.visible_[a.id] = true } }, getBounds: function (a) { if (!this.polygons_[a][0]) return false; return this.polygons_[a][0].getBounds() }, remove: function (a) { if (this.added_[a.id]) { for (var b = 0; b < this.polygons_[a.id].length; b++) { this.map_.removeOverlay(this.polygons_[a.id][b]) } this.added_[a.id] = false; this.visible_[a.id] = false } }, show: function (a) { if (!this.polygons_[a]) return false; if (!this.visible_[a]) { for (var b = 0; b < this.polygons_[a].length; b++) { this.polygons_[a][b].show() } this.visible_[a] = true } }, hide: function (a) { if (!this.polygons_[a]) return false; if (this.visible_[a]) { for (var b = 0; b < this.polygons_[a].length; b++) { this.polygons_[a][b].hide(); this.visible_[a] = false } } }, fitAll: function (a, b) { if (!this.polygons_[b][0]) return false; var c = this.polygons_[b][0].getBounds(); var d = this.map_.getZoom(); var e = this.map_.getBoundsZoomLevel(c); if (!this.map_.getBounds().containsBounds(c) || a) { if (d <= e && Math.abs(d - e) < 2 && !a) { this.map_.panTo(c.getCenter()) } else { this.map_.setCenter(c.getCenter(), e) } } else if (Math.abs(d - e) >= 2) { this.map_.setCenter(c.getCenter(), e) } } }; var SAreaColors = { orange: { color: "#f68d1e", shadow: "#7b460f" }, cyan: { color: "#00a3e1", shadow: "#005170" }, red: { color: "#ee3223", shadow: "#771911"} }; SArea.prototype = { test: function () { alert("test") }, iconMouseover: function () { this.polygon_.add(this.polygonDefinitions_.mouseover) }, iconMouseout: function () { this.polygon_.remove(this.polygonDefinitions_.mouseover) }, iconClick: function () { if (this.status_ != 0) { this.polygon_.remove(this.polygonDefinitions_.on); this.icon_.off(); this.status_ = 0 } else { this.polygon_.add(this.polygonDefinitions_.on); this.icon_.on(); this.status_ = 1 } this.raise({ id: this.id_, status: this.status_ }) }, remove: function () { this.map_.removeOverlay(this.icon_); this.polygon_.remove(this.polygonDefinitions_.on); this.polygon_.remove(this.polygonDefinitions_.mouseover) }, on: function () { this.polygon_.add(this.polygonDefinitions_.on); this.icon_.on(); this.status_ = 1 }, off: function () { this.polygon_.remove(this.polygonDefinitions_.on); this.icon_.off(); this.status_ = 0 }, addHandler: function (a) { this._eventHandlers.push(a) }, raise: function (a) { for (var b = 0; b < this._eventHandlers.length; b++) { this._eventHandlers[b](a) } } }
