Files
openlayers/lib/OpenLayers/Marker/Box.js
crschmidt 526298ea2e Pullups for 2.2-rc2:
#371, Link to license broken
 #376, Fix tile.clear() calls that got overrun during removal of Prototype.js
 #374, Need to bring up new licenses into 2.2 Branch
 #336, create OpenLayers.Layer.Graphic to layers created with simple static images
 #375, No need to exlude Yahoo.js from singlefile build


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.2@1740 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-10-27 14:26:28 +00:00

75 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @class
*
* @requires OpenLayers/Marker.js
*/
OpenLayers.Marker.Box = OpenLayers.Class.create();
OpenLayers.Marker.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Marker, {
/** @type OpenLayers.LonLat */
bounds: null,
div: null,
/**
* @constructor
*
* @param {OpenLayers.Icon} icon
* @param {OpenLayers.LonLat lonlat
*/
initialize: function(bounds, borderColor, borderWidth) {
this.bounds = bounds;
this.div = OpenLayers.Util.createDiv();
this.div.style.overflow = 'hidden';
this.events = new OpenLayers.Events(this, this.div, null);
this.setBorder(borderColor, borderWidth);
},
setBorder: function (color, width) {
if (!color) color = "red";
if (!width) width = 2;
this.div.style.border = width + "px solid " + color;
},
/**
* @param {OpenLayers.Pixel} px
*
* @return A new DOM Image with this marker´s icon set at the
* location passed-in
* @type DOMElement
*/
draw: function(px, sz) {
OpenLayers.Util.modifyDOMElement(this.div, null, px, sz);
return this.div;
},
/**
* @returns Whether or not the marker is currently visible on screen.
* @type Boolean
*/
onScreen:function() {
var onScreen = false;
if (this.map) {
var screenBounds = this.map.getExtent();
onScreen = screenBounds.containsBounds(this.bounds, true, true);
}
return onScreen;
},
/** Hide or show the icon
*
* @param {Boolean} display
*/
display: function(display) {
this.div.style.display = (display) ? "" : "none";
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Marker.Box"
});