function WebcamMarker(latlng, opts) { this.latlng = latlng; if (!opts) opts = {}; this.height_ = opts.height || 32; this.width_ = opts.width || 32; this.image_ = opts.image; this.imageOver_ = opts.imageOver; this.clicked_ = 0; } WebcamMarker.prototype = new GOverlay(); WebcamMarker.prototype.initialize = function(map) { var me = this; // Create the DIV representing our WebcamMarker var div = document.createElement("div"); div.style.border = "1px solid grey"; div.style.padding = "2px"; div.style.backgroundColor = "white"; div.style.position = "absolute"; div.style.cursor = 'pointer'; var img = document.createElement("img"); img.src = me.image_; img.style.width = me.width_ + "px"; img.style.height = me.height_ + "px"; div.appendChild(img); GEvent.addDomListener(div, "click", function(event) { me.clicked_ = 1; GEvent.trigger(me, "click"); }); GEvent.addDomListener(div, 'mouseover', function() { div.style.backgroundColor = "#D9D5C7"; div.style.borderColor = "black"; }); GEvent.addDomListener(div, 'mouseout', function() { div.style.backgroundColor = "white"; div.style.borderColor = "grey"; }); map.getPane(G_MAP_MARKER_PANE).appendChild(div); this.map_ = map; this.div_ = div; }; WebcamMarker.prototype.remove = function() { this.div_.parentNode.removeChild(this.div_); }; WebcamMarker.prototype.copy = function() { var opts = {}; opts.color = this.color_; opts.height = this.height_; opts.width = this.width_; opts.image = this.image_; opts.imageOver = this.image_; return new WebcamMarker(this.latlng, opts); }; WebcamMarker.prototype.redraw = function(force) { // We only need to redraw if the coordinate system has changed if (!force) return; // Calculate the DIV coordinates of two opposite corners // of our bounds to get the size and position of our WebcamMarker var divPixel = this.map_.fromLatLngToDivPixel(this.latlng); // Now position our DIV based on the DIV coordinates of our bounds this.div_.style.width = this.width_ + "px"; this.div_.style.height = (this.height_) + "px"; this.div_.style.left = (divPixel.x - ((this.width_ + 6) / 2)) + "px"; this.div_.style.top = (divPixel.y - ((this.height_ + 10) / 2)) + "px"; }; WebcamMarker.prototype.getZIndex = function(m) { return GOverlay.getZIndex(marker.getPoint().lat()) - m.clicked * 10000; }; WebcamMarker.prototype.getPoint = function() { return this.latlng; }; WebcamMarker.prototype.setStyle = function(style) { for (s in style) { this.div_.style[s] = style[s]; } }; WebcamMarker.prototype.setImage = function(image) { this.div_.style.background = 'url("' + image + '")'; };