source: Dev/branches/rest-dojo-ui/client/dojox/geo/openlayers/Feature.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.4 KB
Line 
1define(["dojo/_base/kernel", "dojo/_base/declare", "dojox/geo/openlayers/Map"], function(dojo, declare, Map){
2
3        return declare("dojox.geo.openlayers.Feature", null, {
4                //      summary:
5                //              A Feature encapsulates an item so that it can be added to a Layer.
6                //              This class is not attended to be used as it, but serve as a base class
7                //              for specific features such as GeometryFeature which can display georeferenced
8                //              geometries and WidgetFeature which can display georeferenced widgets.
9                constructor : function(){
10                        //      summary:
11                        //              Construct a new Feature
12                        this._layer = null;
13                        this._coordSys = dojox.geo.openlayers.EPSG4326;
14                },
15
16                getCoordinateSystem : function(){
17                        //      summary:
18                        //              Returns the coordinate system in which coordinates of this feature are expressed.
19                        //      returns: OpenLayers.Projection
20                        //              The coordinate system in which coordinates of this feature are expressed.
21                        return this._coordSys;
22                },
23
24                setCoordinateSystem : function(/* OpenLayers.Projection */cs){
25                        //      summary:
26                        //              Set the coordinate system in which coordinates of this feature are expressed.
27                        //      cs: OpenLayers.Projection
28                        //              The coordinate system in which coordinates of this feature are expressed.
29                        this._coordSys = cs;
30                },
31
32                getLayer : function(){
33                        //      summary:
34                        //              Returns the Layer to which this feature belongs.
35                        //      returns: dojox.geo.openlayers.Layer
36                        //              The layer to which this feature belongs.
37                        return this._layer;
38                },
39
40                _setLayer : function(/* dojox.geo.openlayers.Layer */l){
41                        //      summary:
42                        //              Sets the layer to which this Feature belongs
43                        //      description:
44                        //              Called when the feature is added to the Layer.
45                        //      tags:
46                        //              private
47                        this._layer = l;
48                },
49
50                render : function(){
51                //      summary:
52                //              subclasses implements drawing specific behavior.
53                },
54
55                remove : function(){
56                //      summary:
57                //              Subclasses implements specific behavior.
58                //              Called when removed from the layer.
59                },
60
61                _getLocalXY : function(p){
62                        //      summary:
63                        //              From projected coordinates to screen coordinates
64                        //      p: Object
65                        //              Object with x and y fields
66                        //      tags:
67                        //              private
68                        var x = p.x;
69                        var y = p.y;
70                        var layer = this.getLayer();
71                        var resolution = layer.olLayer.map.getResolution();
72                        var extent = layer.olLayer.getExtent();
73                        var rx = (x / resolution + (-extent.left / resolution));
74                        var ry = ((extent.top / resolution) - y / resolution);
75                        return [rx, ry];
76                }
77        });
78});
Note: See TracBrowser for help on using the repository browser.