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. */
6 * @requires OpenLayers/Layer/EventPane.js
7 * @requires OpenLayers/Layer/FixedZoomLevels.js
11 * Class: OpenLayers.Layer.MultiMap
12 * Note that MultiMap does not fully support the sphericalMercator
13 * option. See Ticket #953 for more details.
16 * - <OpenLayers.Layer.EventPane>
17 * - <OpenLayers.Layer.FixedZoomLevels>
19 OpenLayers.Layer.MultiMap = OpenLayers.Class(
20 OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {
23 * Constant: MIN_ZOOM_LEVEL
29 * Constant: MAX_ZOOM_LEVEL
35 * Constant: RESOLUTIONS
36 * {Array(Float)} Hardcode these resolutions so that they are more closely
37 * tied with the standard wms projection
55 0.0000858306884765625,
56 0.00004291534423828125
66 * Constructor: OpenLayers.Layer.MultiMap
72 initialize: function(name, options) {
73 OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
74 OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this,
76 if (this.sphericalMercator) {
77 OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
78 this.initMercatorParameters();
79 this.RESOLUTIONS.unshift(10);
84 * Method: loadMapObject
86 loadMapObject:function() {
87 try { //crash proofing
88 this.mapObject = new MultimapViewer(this.div);
93 * APIMethod: getWarningHTML
96 * {String} String with information on why layer is broken, how to get
99 getWarningHTML:function() {
100 return OpenLayers.i18n(
101 "getLayerWarning", {'layerType':"MM", 'layerLib':"MultiMap"}
107 /************************************
109 * MapObject Interface Controls *
111 ************************************/
114 // Get&Set Center, Zoom
117 * APIMethod: setMapObjectCenter
118 * Set the mapObject to the specified center and zoom
121 * center - {Object} MapObject LonLat format
122 * zoom - {int} MapObject zoom format
124 setMapObjectCenter: function(center, zoom) {
125 this.mapObject.goToPosition(center, zoom);
129 * APIMethod: getMapObjectCenter
132 * {Object} The mapObject's current center in Map Object format
134 getMapObjectCenter: function() {
135 return this.mapObject.getCurrentPosition();
139 * APIMethod: getMapObjectZoom
142 * {Integer} The mapObject's current zoom, in Map Object format
144 getMapObjectZoom: function() {
145 return this.mapObject.getZoomFactor();
149 // LonLat - Pixel Translation
152 * APIMethod: getMapObjectLonLatFromMapObjectPixel
155 * moPixel - {Object} MapObject Pixel format
158 * {Object} MapObject LonLat translated from MapObject Pixel
160 getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
161 moPixel.x = moPixel.x - (this.map.getSize().w/2);
162 moPixel.y = moPixel.y - (this.map.getSize().h/2);
163 return this.mapObject.getMapPositionAt(moPixel);
167 * APIMethod: getMapObjectPixelFromMapObjectLonLat
170 * moLonLat - {Object} MapObject LonLat format
173 * {Object} MapObject Pixel transtlated from MapObject LonLat
175 getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
176 return this.mapObject.geoPosToContainerPixels(moLonLat);
180 /************************************
182 * MapObject Primitives *
184 ************************************/
190 * APIMethod: getLongitudeFromMapObjectLonLat
193 * moLonLat - {Object} MapObject LonLat format
196 * {Float} Longitude of the given MapObject LonLat
198 getLongitudeFromMapObjectLonLat: function(moLonLat) {
199 return this.sphericalMercator ?
200 this.forwardMercator(moLonLat.lon, moLonLat.lat).lon :
205 * APIMethod: getLatitudeFromMapObjectLonLat
208 * moLonLat - {Object} MapObject LonLat format
211 * {Float} Latitude of the given MapObject LonLat
213 getLatitudeFromMapObjectLonLat: function(moLonLat) {
214 return this.sphericalMercator ?
215 this.forwardMercator(moLonLat.lon, moLonLat.lat).lat :
220 * APIMethod: getMapObjectLonLatFromLonLat
227 * {Object} MapObject LonLat built from lon and lat params
229 getMapObjectLonLatFromLonLat: function(lon, lat) {
231 if(this.sphericalMercator) {
232 var lonlat = this.inverseMercator(lon, lat);
233 mmLatLon = new MMLatLon(lonlat.lat, lonlat.lon);
235 mmLatLon = new MMLatLon(lat, lon);
243 * APIMethod: getXFromMapObjectPixel
246 * moPixel - {Object} MapObject Pixel format
249 * {Integer} X value of the MapObject Pixel
251 getXFromMapObjectPixel: function(moPixel) {
256 * APIMethod: getYFromMapObjectPixel
259 * moPixel - {Object} MapObject Pixel format
262 * {Integer} Y value of the MapObject Pixel
264 getYFromMapObjectPixel: function(moPixel) {
269 * APIMethod: getMapObjectPixelFromXY
276 * {Object} MapObject Pixel from x and y parameters
278 getMapObjectPixelFromXY: function(x, y) {
279 return new MMPoint(x, y);
282 CLASS_NAME: "OpenLayers.Layer.MultiMap"