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
77 lines
2.3 KiB
JavaScript
77 lines
2.3 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/Layer.js
|
|
* @requires OpenLayers/Layer/Markers.js
|
|
*
|
|
* Class: OpenLayers.Layer.Boxes
|
|
* Draw divs as 'boes' on the layer.
|
|
*
|
|
* Inherits from:
|
|
* - <OpenLayers.Layer.Markers>
|
|
*/
|
|
OpenLayers.Layer.Boxes = OpenLayers.Class.create();
|
|
OpenLayers.Layer.Boxes.prototype =
|
|
OpenLayers.Class.inherit( OpenLayers.Layer.Markers, {
|
|
|
|
/**
|
|
* Constructor: OpenLayers.Layer.Boxes
|
|
*
|
|
* Parameters:
|
|
* name - {String}
|
|
* options - {Object} Hashtable of extra options to tag onto the layer
|
|
*/
|
|
initialize: function (name, options) {
|
|
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
|
|
},
|
|
|
|
/**
|
|
* Method: drawMarker
|
|
* Calculate the pixel location for the marker, create it, and
|
|
* add it to the layer's div
|
|
*
|
|
* Parameters:
|
|
* marker - {<OpenLayers.Marker.Box>}
|
|
*/
|
|
drawMarker: function(marker) {
|
|
var bounds = marker.bounds;
|
|
var topleft = this.map.getLayerPxFromLonLat(
|
|
new OpenLayers.LonLat(bounds.left, bounds.top));
|
|
var botright = this.map.getLayerPxFromLonLat(
|
|
new OpenLayers.LonLat(bounds.right, bounds.bottom));
|
|
if (botright == null || topleft == null) {
|
|
marker.display(false);
|
|
} else {
|
|
var sz = new OpenLayers.Size(
|
|
Math.max(1, botright.x - topleft.x),
|
|
Math.max(1, botright.y - topleft.y));
|
|
var markerDiv = marker.draw(topleft, sz);
|
|
if (!marker.drawn) {
|
|
this.div.appendChild(markerDiv);
|
|
marker.drawn = true;
|
|
}
|
|
}
|
|
},
|
|
|
|
|
|
/**
|
|
* APIMethod: removeMarker
|
|
*
|
|
* Parameters:
|
|
* marker - {<OpenLayers.Marker.Box>}
|
|
*/
|
|
removeMarker: function(marker) {
|
|
OpenLayers.Util.removeItem(this.markers, marker);
|
|
if ((marker.div != null) &&
|
|
(marker.div.parentNode == this.div) ) {
|
|
this.div.removeChild(marker.div);
|
|
}
|
|
},
|
|
|
|
/** @final @type String */
|
|
CLASS_NAME: "OpenLayers.Layer.Boxes"
|
|
});
|