1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
7 * @requires OpenLayers/Layer.js
8 * @requires OpenLayers/Layer/Markers.js
12 * Class: OpenLayers.Layer.Boxes
13 * Draw divs as 'boxes' on the layer.
16 * - <OpenLayers.Layer.Markers>
18 OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, {
21 * Constructor: OpenLayers.Layer.Boxes
25 * options - {Object} Hashtable of extra options to tag onto the layer
27 initialize: function (name, options) {
28 OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
33 * Calculate the pixel location for the marker, create it, and
34 * add it to the layer's div
37 * marker - {<OpenLayers.Marker.Box>}
39 drawMarker: function(marker) {
40 var bounds = marker.bounds;
41 var topleft = this.map.getLayerPxFromLonLat(
42 new OpenLayers.LonLat(bounds.left, bounds.top));
43 var botright = this.map.getLayerPxFromLonLat(
44 new OpenLayers.LonLat(bounds.right, bounds.bottom));
45 if (botright == null || topleft == null) {
46 marker.display(false);
48 var sz = new OpenLayers.Size(
49 Math.max(1, botright.x - topleft.x),
50 Math.max(1, botright.y - topleft.y));
51 var markerDiv = marker.draw(topleft, sz);
53 this.div.appendChild(markerDiv);
61 * APIMethod: removeMarker
64 * marker - {<OpenLayers.Marker.Box>}
66 removeMarker: function(marker) {
67 OpenLayers.Util.removeItem(this.markers, marker);
68 if ((marker.div != null) &&
69 (marker.div.parentNode == this.div) ) {
70 this.div.removeChild(marker.div);
74 CLASS_NAME: "OpenLayers.Layer.Boxes"