]> dev.renevier.net Git - syp.git/blob - openlayers/lib/OpenLayers/Layer/Boxes.js
update german translation
[syp.git] / openlayers / lib / OpenLayers / Layer / Boxes.js
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. */
4
5
6 /**
7  * @requires OpenLayers/Layer.js
8  * @requires OpenLayers/Layer/Markers.js
9  */
10
11 /**
12  * Class: OpenLayers.Layer.Boxes
13  * Draw divs as 'boxes' on the layer. 
14  *
15  * Inherits from:
16  *  - <OpenLayers.Layer.Markers>
17  */
18 OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, {
19
20     /**
21      * Constructor: OpenLayers.Layer.Boxes
22      *
23      * Parameters:
24      * name - {String} 
25      * options - {Object} Hashtable of extra options to tag onto the layer
26      */
27     initialize: function (name, options) {
28         OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
29     },
30     
31     /**
32      * Method: drawMarker 
33      * Calculate the pixel location for the marker, create it, and
34      *    add it to the layer's div
35      *
36      * Parameters: 
37      * marker - {<OpenLayers.Marker.Box>} 
38      */
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);
47         } else {
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);
52             if (!marker.drawn) {
53                 this.div.appendChild(markerDiv);
54                 marker.drawn = true;
55             }
56         }
57     },
58
59
60     /**
61      * APIMethod: removeMarker 
62      * 
63      * Parameters:
64      * marker - {<OpenLayers.Marker.Box>} 
65      */
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);    
71         }
72     },
73
74     CLASS_NAME: "OpenLayers.Layer.Boxes"
75 });