has been done in the NaturalDocs branch back to trunk. Thanks to everyone who helped out in making this happen. (I could list people, but the list would be long, and I'm already mentally on vacation.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@3545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
121 lines
2.8 KiB
JavaScript
121 lines
2.8 KiB
JavaScript
/* 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. */
|
||
|
||
|
||
/**
|
||
* @requires OpenLayers/Marker.js
|
||
*
|
||
* Class: OpenLayers.Marker.Box
|
||
*
|
||
* Inherits from:
|
||
* - <OpenLayers.Marker>
|
||
*/
|
||
OpenLayers.Marker.Box = OpenLayers.Class.create();
|
||
OpenLayers.Marker.Box.prototype =
|
||
OpenLayers.Class.inherit( OpenLayers.Marker, {
|
||
|
||
/**
|
||
* Property: bounds
|
||
* {<OpenLayers.Bounds>}
|
||
*/
|
||
bounds: null,
|
||
|
||
/**
|
||
* Property: div
|
||
* {DOMElement}
|
||
*/
|
||
div: null,
|
||
|
||
/**
|
||
* Constructor: OpenLayers.Marker.Box
|
||
*
|
||
* Parameters:
|
||
* bounds - {<OpenLayers.Bounds>}
|
||
* borderColor - {String}
|
||
* borderWidth - {int}
|
||
*/
|
||
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);
|
||
},
|
||
|
||
/**
|
||
* Method: destroy
|
||
*/
|
||
destroy: function() {
|
||
|
||
this.bounds = null;
|
||
this.div = null;
|
||
|
||
OpenLayers.Marker.prototype.destroy.apply(this, arguments);
|
||
},
|
||
|
||
/**
|
||
* Method: setBorder
|
||
* Allow the user to change the box's color and border width
|
||
*
|
||
* Parameters:
|
||
* color - {String} Default is "red"
|
||
* width - {int} Default is 2
|
||
*/
|
||
setBorder: function (color, width) {
|
||
if (!color) {
|
||
color = "red";
|
||
}
|
||
if (!width) {
|
||
width = 2;
|
||
}
|
||
this.div.style.border = width + "px solid " + color;
|
||
},
|
||
|
||
/**
|
||
* Method: draw
|
||
*
|
||
* Parameters:
|
||
* px - {<OpenLayers.Pixel>}
|
||
* sz - {<OpenLayers.Size>}
|
||
*
|
||
* Return:
|
||
* {DOMElement} A new DOM Image with this marker´s icon set at the
|
||
* location passed-in
|
||
*/
|
||
draw: function(px, sz) {
|
||
OpenLayers.Util.modifyDOMElement(this.div, null, px, sz);
|
||
return this.div;
|
||
},
|
||
|
||
/**
|
||
* Method: onScreen
|
||
*
|
||
* Rreturn:
|
||
* {Boolean} Whether or not the marker is currently visible on screen.
|
||
*/
|
||
onScreen:function() {
|
||
var onScreen = false;
|
||
if (this.map) {
|
||
var screenBounds = this.map.getExtent();
|
||
onScreen = screenBounds.containsBounds(this.bounds, true, true);
|
||
}
|
||
return onScreen;
|
||
},
|
||
|
||
/**
|
||
* Method: display
|
||
* Hide or show the icon
|
||
*
|
||
* Parameters:
|
||
* display - {Boolean}
|
||
*/
|
||
display: function(display) {
|
||
this.div.style.display = (display) ? "" : "none";
|
||
},
|
||
|
||
/** @final @type String */
|
||
CLASS_NAME: "OpenLayers.Marker.Box"
|
||
});
|
||
|