~flavour/sahana-eden/trunk

« back to all changes in this revision

Viewing changes to static/scripts/gis/openlayers/lib/OpenLayers/Layer/MultiMap.js

  • Committer: Fran Boon
  • Date: 2012-01-21 16:10:49 UTC
  • Revision ID: fran@aidiq.com-20120121161049-u2ytuiymn1t312c6
JS upgrade: jQuery, jQueryUI, OpenLayers, Ext, GeoExt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for 
2
 
 * full list of contributors). Published under the Clear BSD license.  
3
 
 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4
 
 * full text of the license. */
5
 
 
6
 
/**
7
 
 * @requires OpenLayers/Layer/EventPane.js
8
 
 * @requires OpenLayers/Layer/FixedZoomLevels.js
9
 
 * @requires OpenLayers/Lang.js
10
 
 */
11
 
 
12
 
/**
13
 
 * Class: OpenLayers.Layer.MultiMap
14
 
 * Note that MultiMap does not fully support the sphericalMercator
15
 
 * option. See Ticket #953 for more details.
16
 
 * *Deprecated*.  Use OpenLayers.Layer.Bing instead. See #3063
17
 
 * 
18
 
 * Inherits from:
19
 
 *  - <OpenLayers.Layer.EventPane>
20
 
 *  - <OpenLayers.Layer.FixedZoomLevels>
21
 
 */
22
 
OpenLayers.Layer.MultiMap = OpenLayers.Class(
23
 
  OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {
24
 
    
25
 
    /** 
26
 
     * Constant: MIN_ZOOM_LEVEL
27
 
     * {Integer} 1 
28
 
     */
29
 
    MIN_ZOOM_LEVEL: 1,
30
 
    
31
 
    /** 
32
 
     * Constant: MAX_ZOOM_LEVEL
33
 
     * {Integer} 17
34
 
     */
35
 
    MAX_ZOOM_LEVEL: 17,
36
 
 
37
 
    /** 
38
 
     * Constant: RESOLUTIONS
39
 
     * {Array(Float)} Hardcode these resolutions so that they are more closely
40
 
     *                tied with the standard wms projection
41
 
     */
42
 
    RESOLUTIONS: [
43
 
        9, 
44
 
        1.40625,
45
 
        0.703125,
46
 
        0.3515625,
47
 
        0.17578125,
48
 
        0.087890625,
49
 
        0.0439453125,
50
 
        0.02197265625,
51
 
        0.010986328125,
52
 
        0.0054931640625,
53
 
        0.00274658203125,
54
 
        0.001373291015625,
55
 
        0.0006866455078125,
56
 
        0.00034332275390625,
57
 
        0.000171661376953125,
58
 
        0.0000858306884765625,
59
 
        0.00004291534423828125
60
 
    ],
61
 
 
62
 
    /**
63
 
     * APIProperty: type
64
 
     * {?}
65
 
     */
66
 
    type: null,
67
 
 
68
 
    /** 
69
 
     * Constructor: OpenLayers.Layer.MultiMap
70
 
     * 
71
 
     * Parameters:
72
 
     * name - {String}
73
 
     * options - {Object}
74
 
     */
75
 
    initialize: function(name, options) {
76
 
        OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
77
 
        OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 
78
 
                                                                    arguments);
79
 
        if (this.sphericalMercator) {
80
 
            OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
81
 
            this.initMercatorParameters();
82
 
            this.RESOLUTIONS.unshift(10); 
83
 
        }    
84
 
    },
85
 
    
86
 
    /**
87
 
     * Method: loadMapObject
88
 
     */
89
 
    loadMapObject:function() {
90
 
        try { //crash proofing
91
 
            this.mapObject = new MultimapViewer(this.div);
92
 
        } catch (e) { }
93
 
    },
94
 
 
95
 
    /** 
96
 
     * APIMethod: getWarningHTML
97
 
     * 
98
 
     * Returns: 
99
 
     * {String} String with information on why layer is broken, how to get
100
 
     *          it working.
101
 
     */
102
 
    getWarningHTML:function() {
103
 
        return OpenLayers.i18n(
104
 
            "getLayerWarning", {'layerType':"MM", 'layerLib':"MultiMap"}
105
 
        );
106
 
    },
107
 
 
108
 
 
109
 
 
110
 
    /************************************
111
 
     *                                  *
112
 
     *   MapObject Interface Controls   *
113
 
     *                                  *
114
 
     ************************************/
115
 
 
116
 
 
117
 
  // Get&Set Center, Zoom
118
 
 
119
 
    /** 
120
 
     * APIMethod: setMapObjectCenter
121
 
     * Set the mapObject to the specified center and zoom
122
 
     * 
123
 
     * Parameters:
124
 
     * center - {Object} MapObject LonLat format
125
 
     * zoom - {int} MapObject zoom format
126
 
     */
127
 
    setMapObjectCenter: function(center, zoom) {
128
 
        this.mapObject.goToPosition(center, zoom); 
129
 
    },
130
 
   
131
 
    /**
132
 
     * APIMethod: getMapObjectCenter
133
 
     * 
134
 
     * Returns: 
135
 
     * {Object} The mapObject's current center in Map Object format
136
 
     */
137
 
    getMapObjectCenter: function() {
138
 
        return this.mapObject.getCurrentPosition();
139
 
    },
140
 
 
141
 
    /** 
142
 
     * APIMethod: getMapObjectZoom
143
 
     * 
144
 
     * Returns:
145
 
     * {Integer} The mapObject's current zoom, in Map Object format
146
 
     */
147
 
    getMapObjectZoom: function() {
148
 
        return this.mapObject.getZoomFactor();
149
 
    },
150
 
 
151
 
 
152
 
  // LonLat - Pixel Translation
153
 
  
154
 
    /**
155
 
     * APIMethod: getMapObjectLonLatFromMapObjectPixel
156
 
     * 
157
 
     * Parameters:
158
 
     * moPixel - {Object} MapObject Pixel format
159
 
     * 
160
 
     * Returns:
161
 
     * {Object} MapObject LonLat translated from MapObject Pixel
162
 
     */
163
 
    getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
164
 
        moPixel.x = moPixel.x - (this.map.getSize().w/2);
165
 
        moPixel.y = moPixel.y - (this.map.getSize().h/2);
166
 
        return this.mapObject.getMapPositionAt(moPixel);
167
 
    },
168
 
 
169
 
    /**
170
 
     * APIMethod: getMapObjectPixelFromMapObjectLonLat
171
 
     * 
172
 
     * Parameters:
173
 
     * moLonLat - {Object} MapObject LonLat format
174
 
     * 
175
 
     * Returns:
176
 
     * {Object} MapObject Pixel transtlated from MapObject LonLat
177
 
     */
178
 
    getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
179
 
        return this.mapObject.geoPosToContainerPixels(moLonLat);
180
 
    },
181
 
 
182
 
 
183
 
    /************************************
184
 
     *                                  *
185
 
     *       MapObject Primitives       *
186
 
     *                                  *
187
 
     ************************************/
188
 
 
189
 
 
190
 
  // LonLat
191
 
    
192
 
    /**
193
 
     * APIMethod: getLongitudeFromMapObjectLonLat
194
 
     * 
195
 
     * Parameters:
196
 
     * moLonLat - {Object} MapObject LonLat format
197
 
     * 
198
 
     * Returns:
199
 
     * {Float} Longitude of the given MapObject LonLat
200
 
     */
201
 
    getLongitudeFromMapObjectLonLat: function(moLonLat) {
202
 
        return this.sphericalMercator ? 
203
 
            this.forwardMercator(moLonLat.lon, moLonLat.lat).lon :
204
 
            moLonLat.lon;
205
 
    },
206
 
 
207
 
    /**
208
 
     * APIMethod: getLatitudeFromMapObjectLonLat
209
 
     * 
210
 
     * Parameters:
211
 
     * moLonLat - {Object} MapObject LonLat format
212
 
     * 
213
 
     * Returns:
214
 
     * {Float} Latitude of the given MapObject LonLat
215
 
     */
216
 
    getLatitudeFromMapObjectLonLat: function(moLonLat) {
217
 
        return this.sphericalMercator ? 
218
 
            this.forwardMercator(moLonLat.lon, moLonLat.lat).lat :
219
 
            moLonLat.lat;
220
 
    },
221
 
 
222
 
    /**
223
 
     * APIMethod: getMapObjectLonLatFromLonLat
224
 
     * 
225
 
     * Parameters:
226
 
     * lon - {Float}
227
 
     * lat - {Float}
228
 
     * 
229
 
     * Returns:
230
 
     * {Object} MapObject LonLat built from lon and lat params
231
 
     */
232
 
    getMapObjectLonLatFromLonLat: function(lon, lat) {
233
 
        var mmLatLon;
234
 
        if(this.sphericalMercator) {
235
 
            var lonlat = this.inverseMercator(lon, lat);
236
 
            mmLatLon = new MMLatLon(lonlat.lat, lonlat.lon);
237
 
        } else {
238
 
            mmLatLon = new MMLatLon(lat, lon);
239
 
        }
240
 
        return mmLatLon;
241
 
    },
242
 
 
243
 
  // Pixel
244
 
    
245
 
    /**
246
 
     * APIMethod: getXFromMapObjectPixel
247
 
     * 
248
 
     * Parameters:
249
 
     * moPixel - {Object} MapObject Pixel format
250
 
     * 
251
 
     * Returns:
252
 
     * {Integer} X value of the MapObject Pixel
253
 
     */
254
 
    getXFromMapObjectPixel: function(moPixel) {
255
 
        return moPixel.x;
256
 
    },
257
 
 
258
 
    /**
259
 
     * APIMethod: getYFromMapObjectPixel
260
 
     * 
261
 
     * Parameters:
262
 
     * moPixel - {Object} MapObject Pixel format
263
 
     * 
264
 
     * Returns:
265
 
     * {Integer} Y value of the MapObject Pixel
266
 
     */
267
 
    getYFromMapObjectPixel: function(moPixel) {
268
 
        return moPixel.y;
269
 
    },
270
 
 
271
 
    /**
272
 
     * APIMethod: getMapObjectPixelFromXY
273
 
     * 
274
 
     * Parameters:
275
 
     * x - {Integer}
276
 
     * y - {Integer}
277
 
     * 
278
 
     * Returns:
279
 
     * {Object} MapObject Pixel from x and y parameters
280
 
     */
281
 
    getMapObjectPixelFromXY: function(x, y) {
282
 
        return new MMPoint(x, y);
283
 
    },
284
 
 
285
 
    CLASS_NAME: "OpenLayers.Layer.MultiMap"
286
 
});