source: ether_iasi/trunk/web/resources/js/OpenLayers-2.12/lib/OpenLayers/Layer/Boxes.js @ 738

Last change on this file since 738 was 738, checked in by vmipsl, 11 years ago

OpenLayers?

File size: 2.1 KB
Line 
1/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the 2-clause BSD license.
3 * See license.txt in the OpenLayers distribution or repository for the
4 * full text of the license. */
5
6
7/**
8 * @requires OpenLayers/Layer.js
9 * @requires OpenLayers/Layer/Markers.js
10 */
11
12/**
13 * Class: OpenLayers.Layer.Boxes
14 * Draw divs as 'boxes' on the layer.
15 *
16 * Inherits from:
17 *  - <OpenLayers.Layer.Markers>
18 */
19OpenLayers.Layer.Boxes = OpenLayers.Class(OpenLayers.Layer.Markers, {
20
21    /**
22     * Constructor: OpenLayers.Layer.Boxes
23     *
24     * Parameters:
25     * name - {String}
26     * options - {Object} Hashtable of extra options to tag onto the layer
27     */
28   
29    /**
30     * Method: drawMarker
31     * Calculate the pixel location for the marker, create it, and
32     *    add it to the layer's div
33     *
34     * Parameters:
35     * marker - {<OpenLayers.Marker.Box>}
36     */
37    drawMarker: function(marker) {
38        var topleft = this.map.getLayerPxFromLonLat({
39            lon: marker.bounds.left,
40            lat: marker.bounds.top
41        });
42        var botright = this.map.getLayerPxFromLonLat({
43            lon: marker.bounds.right,
44            lat: marker.bounds.bottom
45        });
46        if (botright == null || topleft == null) {
47            marker.display(false);
48        } else {
49            var markerDiv = marker.draw(topleft, {
50                w: Math.max(1, botright.x - topleft.x),
51                h: Math.max(1, botright.y - topleft.y)
52            });
53            if (!marker.drawn) {
54                this.div.appendChild(markerDiv);
55                marker.drawn = true;
56            }
57        }
58    },
59
60
61    /**
62     * APIMethod: removeMarker
63     *
64     * Parameters:
65     * marker - {<OpenLayers.Marker.Box>}
66     */
67    removeMarker: function(marker) {
68        OpenLayers.Util.removeItem(this.markers, marker);
69        if ((marker.div != null) &&
70            (marker.div.parentNode == this.div) ) {
71            this.div.removeChild(marker.div);   
72        }
73    },
74
75    CLASS_NAME: "OpenLayers.Layer.Boxes"
76});
Note: See TracBrowser for help on using the repository browser.