[fusion-commits] r2098 - in trunk: layers layers/Generic
layers/MapGuide layers/MapServer lib widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Mar 15 15:51:14 EDT 2010
Author: madair
Date: 2010-03-15 15:51:13 -0400 (Mon, 15 Mar 2010)
New Revision: 2098
Modified:
trunk/layers/Generic/Generic.js
trunk/layers/Layers.js
trunk/layers/MapGuide/MapGuide.js
trunk/layers/MapServer/MapServer.js
trunk/lib/ApplicationDefinition.js
trunk/lib/Map.js
trunk/widgets/MapMenu.js
Log:
re #315: use consistent handling of projection and units - set a reasonable default value in AppDef.js when parsing the AppDef, but values may be overridden by LoadMap response. Let OL handle setting up it's units/projection via addLayer().
Modified: trunk/layers/Generic/Generic.js
===================================================================
--- trunk/layers/Generic/Generic.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/layers/Generic/Generic.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -174,7 +174,7 @@
this.mapTag.layerOptions.maxExtent = new OpenLayers.Bounds(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892);
}
this.mapTag.layerOptions.units = "m";
- this.mapTag.layerOptions.projection = "EPSG:900913";
+ this.mapTag.layerOptions.projection = "EPSG:3785";
} else {
if (!this.mapTag.layerOptions.maxExtent) {
this.mapTag.layerOptions.maxExtent = new OpenLayers.Bounds(-180,-90,180,90);
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/layers/Layers.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -48,7 +48,6 @@
noCache: false,
_sMapTitle: null,
_sMapname: null,
- projCode: null,
initialize: function(map, mapTag, isMapWidgetLayer) {
// console.log('Fusion.Layers.initialize');
Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/layers/MapGuide/MapGuide.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -86,9 +86,6 @@
}
}
- //copy over projection info from maptag
- this.projCode = mapTag.projCode;
-
rootOpts = {
displayInLegend: this.bDisplayInLegend,
expandInLegend: this.bExpandInLegend,
@@ -304,14 +301,11 @@
//set projection units and code if supplied
if (o.epsg != 0) {
- this.projCode = "EPSG:" + o.epsg;
+ this.mapTag.layerOptions.projection = "EPSG:" + o.epsg;
}
//TODO: consider passing the metersPerUnit value into the framework
//to allow for scaling that doesn't match any of the pre-canned units
- this.units = Fusion.getClosestUnits(o.metersPerUnit);
- if (this.projCode) {
- this.mapWidget.setProjection(this.projCode, this.units);
- }
+ this.mapTag.layerOptions.units = Fusion.getClosestUnits(o.metersPerUnit);
//add in scales array if supplied
if (o.FiniteDisplayScales && o.FiniteDisplayScales.length>0) {
@@ -579,8 +573,6 @@
}
var layerOptions = {
- units: this.units,
- projection: this.projCode,
maxResolution: 'auto',
useOverlay: this.selectionAsOverlay,
useAsyncOverlay: this.useAsyncOverlay,
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/layers/MapServer/MapServer.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -254,16 +254,12 @@
if (o.projString.length > 0) {
var epsg = o.projString.indexOf("init=");
if (epsg >= 0) {
- this.projCode = o.projString.substring(epsg+5).toUpperCase();
+ this.mapTag.layerOptions.projection = o.projString.substring(epsg+5).toUpperCase();
} else {
- this.projCode = o.mapName.toUpperCase();
- Proj4js.defs[this.projCode] = o.projString;
+ this.mapTag.layerOptions.projection = o.mapName.toUpperCase();
+ Proj4js.defs[this.mapTag.layerOptions.projection] = o.projString;
}
}
- if (this.projCode) {
- this.mapWidget.setProjection(this.projCode);
- }
- this.mapWidget.setMetersPerUnit(o.metersPerUnit);
this.mapTag.layerOptions.maxExtent = OpenLayers.Bounds.fromArray(o.extent);
@@ -293,12 +289,11 @@
}
//to allow for scaling that doesn't match any of the pre-canned units
- this.units = Fusion.getClosestUnits(o.metersPerUnit);
+ this.mapTag.layerOptions.units = Fusion.getClosestUnits(o.metersPerUnit);
var layerOptions = {
singleTile: true,
ratio: this.ratio,
- units: this.units,
maxResolution: 'auto',
minScale: maxScale, //OL interpretation of min/max scale is reversed from Fusion
maxScale: minScale
@@ -330,7 +325,6 @@
if (this.bIsMapWidgetLayer) {
this.mapWidget.addMap(this);
- this.mapWidget.oMapOL.units = this.oLayerOL.units;
}
this.bMapLoaded = true;
}
Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/lib/ApplicationDefinition.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -486,7 +486,6 @@
type: null,
singleTile: false,
extension: null,
- projCode: null,
initialize: function(jsonNode) {
/* TODO: type can be any supported OpenLayers type */
@@ -526,19 +525,19 @@
}
//projection info from the extension
- //this.projCode = "EPSG:4326"; //default to WGS84 lat long
+ //this.layerOptions.projection = "EPSG:4326"; //default to WGS84 lat long
if (this.extension.ProjectionCode) {
- this.projCode = this.extension.ProjectionCode[0];
+ this.layerOptions.projection = this.extension.ProjectionCode[0];
}
if (this.extension.ProjectionDef) {
var projDef = this.extension.ProjectionDef[0];
- if (!this.projCode) {
- this.projCode = "APP-DEF-PROJ";
+ if (!this.layerOptions.projection) {
+ this.layerOptions.projection = "APP-DEF-PROJ";
}
- Proj4js.defs[this.projCode] = projDef;
+ Proj4js.defs[this.layerOptions.projection] = projDef;
}
- if (!this.projCode) {
- this.projCode = "EPSG:4326";
+ if (!this.layerOptions.projection) {
+ this.layerOptions.projection = "EPSG:4326";
}
switch (this.type) {
@@ -551,14 +550,15 @@
case "Google":
case "Yahoo":
case "VirtualEarth":
+ this.layerOptions.isBaseLayer = true;
this.layerOptions.sphericalMercator = true;
this.layerOptions.displayProjection = "EPSG:4326";
//no break here continue below to set EPSG:3785 as projCode
default:
if (this.layerOptions.sphericalMercator) {
- this.projCode = "EPSG:3785"; //commercial map layer projection spherical mercator
+ this.layerOptions.projection = "EPSG:3785"; //commercial map layer projection spherical mercator
} else {
- this.projCode = "EPSG:4326"; //WGS84 lat long
+ this.layerOptions.projection = "EPSG:4326"; //WGS84 lat long
}
if ( !Fusion.Layers.Generic ) {
Fusion.require('layers/Generic/Generic.js');
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/lib/Map.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -27,6 +27,7 @@
* Class: Fusion.Widget.Map
*
* generic class for map widgets. Provides common utility classes.
+ * This class provides a wrapper around the OpenLayers Map object.
* **********************************************************************/
Fusion.Event.MAP_EXTENTS_CHANGED = Fusion.Event.lastEventId++;
@@ -52,37 +53,69 @@
Fusion.Constant.LAYER_DWF_TYPE = 5;
Fusion.Widget.Map = OpenLayers.Class(Fusion.Lib.EventMgr, {
+
+ /** The DOM object that holds the map */
_oDomObj: null,
+
+ /** The id of DOM object */
_sDomObj: '',
+
+ /** The internal name used for the map, usually assigned by the server */
_sMapname: '',
- _nWidth: -1,
- _nHeight: -1,
+
+ /** conversion factor to convert from map units to meters */
_fMetersperunit: -1,
+
+ /** scale denominator value */
_fScale: -1,
+
+ /** Dots per inch setting for the server */
_nDpi: 96,
+
+ /** The current bounds of the map, this is updated on every map draw */
_oCurrentExtents: null,
+
+ /** The maximum extent of the map */
maxExtent: new OpenLayers.Bounds(),
+
+ /** counter of worker threads for the ActivityIndicator widget */
_nWorkers: 0,
+
+ /** The context menu object for right click */
oContextMenu: null,
+
+ /** flag to disable the map context menu, set this in the Map extension */
bSupressContextMenu: false,
-
+
+ /** an array to hold all the individual map layer objects */
aMaps: null,
+
+ /** flag to indicate if all the map layers are loaded */
mapsLoaded: false,
+
+ /** the root of the layer structure for the Legend */
layerRoot: null,
+
+ /** flag to indicate if the map is tiled or not, set in the Map extension */
singleTile: true,
+
+ /** flag to indicate if fractional zoom is supported, ie. allow any scale
+ * value rather than a fixed set of scales
+ */
fractionalZoom: true,
+
+ /** The DOM object that holds the map */
maxScale: null, //set this to a large number in AppDef to zoom out beyond maxExtent, e.g. 1 billion
/**
* construct a new view Fusion.Widget.Map class.
*/
- initialize : function(widgetTag, mapGroup, widgetSet) {
+ initialize: function(widgetTag, mapGroup, widgetSet) {
this.widgetTag = widgetTag;
var name = widgetTag.name;
this.aMaps = [];
this.buttonSet = new Jx.ButtonSet();
this.widgetSet = widgetSet;
- this._nCellSize = -1;
this._sDomObj = name;
this._oDomObj = $(this._sDomObj);
this.layerRoot = new Fusion.Layers.Group({
@@ -101,6 +134,7 @@
this.fractionalZoom = widgetTag.extension.FractionalZoom[0]=='false'?false:true;
}
+ //if there is a scales array specified, use that set and turn off fraczoom
var scalesArray = null;
if (widgetTag.extension.Scales) {
scalesArray = widgetTag.extension.Scales[0].split(',');
@@ -113,11 +147,13 @@
this.maxScale = parseInt(widgetTag.extension.MaxExtent[0]);
}
+ //set the maxExtent
var maxExtent = null;
if (widgetTag.extension.MaxExtent) {
maxExtent = OpenLayers.Bounds.fromString(widgetTag.extension.MaxExtent[0]);
}
+ //create the OpenLayers Map object
OpenLayers.DOTS_PER_INCH = this._nDpi;
if (!this.oMapOL) {
var options = {
@@ -136,6 +172,7 @@
this.oMapOL = new OpenLayers.Map(this._sDomObj, options );
}
+ //Fusion specific modifications to the OL map window style
this.oMapOL.viewPortDiv.style.position = 'absolute'; //not the top level container so set it to absolute
this.oMapOL.viewPortDiv.style.zIndex = 0; //must explicitly set the z-index for FF3
@@ -188,10 +225,28 @@
this.loadMapGroup(mapGroup);
},
+ /**
+ * Function: mapLoaded
+ *
+ * Callback for when all maps have been loaded
+ *
+ * Parameter: none.
+ *
+ * Return: none
+ */
mapLoaded: function() {
this.setViewOptions(this.getUnits());
},
+ /**
+ * Function: setMenu
+ *
+ * Attaches a context menu as defined in the AppDef to the map
+ *
+ * Parameter: none.
+ *
+ * Return: none
+ */
setMenu: function() {
if (this.widgetTag.extension.MenuContainer) {
var contextMenu = new Jx.Menu.Context();
@@ -203,6 +258,15 @@
}
},
+ /**
+ * Function: loadMapGroup
+ *
+ * Controls the creation of Layers based on the MapGroup object passed in
+ *
+ * Parameter: {Object} mapGroup - a representation of the MapGroup object
+ *
+ * Return: none
+ */
loadMapGroup: function(mapGroup) {
//clear any existing selection
this.mapsLoaded = false;
@@ -238,6 +302,17 @@
this.triggerEvent(Fusion.Event.MAP_MAP_GROUP_LOADED);
},
+ /**
+ * Function: layerLoaded
+ *
+ * Called after each layer is loaded in the OL viewport. Nothing happens
+ * here until the last layer is laoded, then it sets the OL baselayer and
+ * zooms to the initial extent.
+ *
+ * Parameter: none
+ *
+ * Return: none
+ */
layerLoaded: function() {
for (var i=0; i<this.aMaps.length; ++i) {
if (!this.aMaps[i].isMapLoaded()) {
@@ -269,10 +344,14 @@
},
/**
- * Method: wheelChange
+ * Function: wheelChange
*
+ * handles mouse wheel events by accummulating the events and setting a timer
+ * to do the actual zoom in/out
+ *
* Parameters:
- * evt - {Event}
+ * evt - {Event} the mouse wheel event object
+ * deltaZ - {Integer} the number of ticks wheeled
*/
wheelChange: function(evt, deltaZ) {
if (this.wheelTimer) {
@@ -285,6 +364,17 @@
this.wheelTimer = setTimeout(OpenLayers.Function.bind(function(){this.doWheelChange(evt, deltaZ);}, this), 200);
},
+ /**
+ * Function: doWheelChange
+ *
+ * Carries out the actual map zoom based on the wheel movement
+ *
+ * Parameters:
+ * evt - {Event} the mouse wheel event object
+ * deltaZ - {Integer} the number of ticks wheeled
+ *
+ * Return: none
+ */
doWheelChange: function(evt, deltaZ) {
this.wheelTimer = null;
if (this.cumulativeDelta == 0) {
@@ -331,50 +421,104 @@
},
/**
- * returns the dom element
+ * Function: getDomObj
+ *
+ * returns the dom element for this widget
+ *
+ * Parameters: none
+ *
+ * Return: none
*/
getDomObj: function() {
return this._oDomObj;
},
+ /**
+ * Function: getMapName
+ *
+ * returns the name of the baselayer map
+ *
+ * Parameters: none
+ *
+ * Return: {String} the name of the baselayer map
+ */
getMapName: function() {
//TODO: what is the mapname in the case of multiple map layer objects?
//just return baselayer mapname for now
return this.aMaps[0].getMapName();
},
+ /**
+ * Function: getMapTitle
+ *
+ * returns the Title of the baselayer map. This is a human-readable title
+ *
+ * Parameters: none
+ *
+ * Return: {String} the Title of the baselayer map
+ */
getMapTitle: function() {
//TODO: what is the map title in the case of multiple map layer objects?
//just return baselayer mapTitle for now
return this.aMaps[0]._sMapTitle;
},
+ /**
+ * Function: getSessionID
+ *
+ * returns the server session ID
+ *
+ * Parameters: none
+ *
+ * Return: {String} the session ID
+ */
getSessionID: function() {
//TODO: what is the mapname in the case of multiple map layer objects?
//just return baselayer session ID for now
return this.aMaps[0].getSessionID();
},
+ /**
+ * Function: getDomId
+ *
+ * returns the ID of dom element for this widget
+ *
+ * Parameters: none
+ *
+ * Return: {String} the id of the DOM element
+ */
getDomId: function() {
return this._sDomObj;
},
+ /**
+ * Function: setMapOptions
+ *
+ * sets options on the OpenLayers map object, a wrapper for the OL function
+ *
+ * Parameters: {Object} options - has of option key/value pairs
+ *
+ * Return: none
+ */
setMapOptions: function(options) {
this.oMapOL.setOptions(options);
},
+ /**
+ * Function: addMap
+ *
+ * adds a map/Layer to the map and registers some event handlers on the map
+ *
+ * Parameters: {Object} map - the map object to tbe added (really a layer object)
+ *
+ * Return: none
+ */
addMap: function(map) {
if (map.mapTag.layerOptions.maxExtent) {
- this.projection = map.projection;
- this.units = map.units;
this.maxExtent.extend(map.mapTag.layerOptions.maxExtent);
- this.oMapOL.setOptions({
- maxExtent: this.maxExtent,
- units: map.units,
- projection: this.projection
- });
+ this.oMapOL.setOptions({maxExtent: this.maxExtent});
}
//if bRestrictExtent is null, use the default OL behaviour with somewhat restricted map navigation
@@ -388,19 +532,44 @@
}
}
this.oMapOL.addLayer(map.oLayerOL);
- map.registerForEvent(Fusion.Event.MAP_LOADED,
- OpenLayers.Function.bind(this.mapLoadHandler, this));
+ if (map.oLayerOL.isBaseLayer) {
+ this.projection = map.projection;
+ this.units = map.units;
+ this.oMapOL.setOptions({
+ units: map.units,
+ projection: this.projection
+ });
+ }
+
map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
OpenLayers.Function.bind(this.selectionHandler, this));
map.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
OpenLayers.Function.bind(this.selectionHandler, this));
},
+ /**
+ * Function: getAllMaps
+ *
+ * returns the array of map objects
+ *
+ * Parameters: none
+ *
+ * Return: {Array} the array of map Objects
+ */
getAllMaps: function() {
return this.aMaps;
},
- //this uses setTimeout so this method can be called from an IFRAME
+ /**
+ * Function: reloadMap
+ *
+ * Called to reload all the map objects.
+ * this uses setTimeout so this method can be called from an IFRAME
+ *
+ * Parameters: none
+ *
+ * Return: none
+ */
reloadMap: function() {
for (var i=0; i<this.aMaps.length; ++i) {
var map = this.aMaps[i];
@@ -408,6 +577,17 @@
}
},
+ /**
+ * Function: loadScaleRanges
+ *
+ * Loads the ScaleRange objects separate from the LoadMap sequence since
+ * this also generates sprites and is a relatively expensive operation.
+ *
+ * Parameters: {Function} userFunc - a user defined function to be called as a
+ * callback
+ *
+ * Return: none
+ */
loadScaleRanges: function(userFunc) {
for (var i=0; i<this.aMaps.length; ++i) {
var map = this.aMaps[i];
@@ -418,7 +598,9 @@
/**
* Function: query
*
- * dispatch query requests to maps
+ * dispatch query requests to the maps
+ *
+ * Parameters: {object} options - query options to be passed to each map
*/
query: function(options) {
this.lastQueryOptions = options;
@@ -429,25 +611,14 @@
},
/**
- * Function: mapLoadHandler
+ * Function: selectionHandler
*
* handle selection events from maps and republish for
* widgets as appropriate
- */
- mapLoadHandler: function() {
- ++this.mapLoadCounter;
- if (this.mapLoadCounter == this.aMaps.length) {
- this._oInitialExtents = null;
- this.fullExtents();
- this.triggerEvent(Fusion.Event.MAP_LOADED);
- }
- },
-
- /**
- * Function: selectionHandler
*
- * handle selection events from maps and republish for
- * widgets as appropriate
+ * Parameters: none
+ *
+ * Return: none
*/
selectionHandler: function() {
if (this.hasSelection()) {
@@ -460,7 +631,9 @@
/**
* Function: hasSelection
*
- * returns true if any map has a selection
+ * cehck to see if any of the maps have an active selection
+ *
+ * Returns: {Boolean} - true if any map has a selection
*/
hasSelection: function() {
for (var i=0; i<this.aMaps.length; i++ ) {
@@ -487,7 +660,7 @@
/**
* Function: getSelection
*
- * returns the current selection asynchronously in case we
+ * initiates a call to get the current selection asynchronously in case we
* need to retrieve the details from the server
*/
getSelection: function(callback, layers, startcount) {
@@ -515,7 +688,11 @@
/**
* Function: setSelection
*
- * sets a Selection XML back to the server
+ * sets a Selection XML back to the server for each of the maps
+ *
+ * Parameters:
+ * {String} selText - the selection string
+ * {Boolean} zoomTo - if set, will zoom to the selection on completion
*/
setSelection: function(selText, zoomTo) {
for (var i=0; i<this.aMaps.length; i++ ) {
@@ -528,6 +705,10 @@
*
* accumulate the selection results from each map and when all have
* reported in, pass the results to the callback function
+ *
+ * Parameters:
+ * {Object} map - the map object that has the selection
+ * {Object} oSelection - the Fusion selection object
*/
accumulateSelection: function(map, oSelection) {
this.oSelection[map._sMapname] = oSelection;
@@ -545,25 +726,33 @@
* Function: setActiveLayer
*
* sets the active layer for selection/manipulation
+ *
+ * Parameters:
+ * {Object} oLayer - the layer to be set as active
*/
- setActiveLayer: function( oLayer ) {
- this.oActiveLayer = oLayer;
- if (oLayer) {
- this.oActiveMap = oLayer.map;
- }
- this.triggerEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, oLayer);
- },
+ setActiveLayer: function( oLayer ) {
+ this.oActiveLayer = oLayer;
+ if (oLayer) {
+ this.oActiveMap = oLayer.map;
+ }
+ this.triggerEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, oLayer);
+ },
/**
* Function: getActiveLayer
*
* returns the active layer for selection/manipulation
+ *
+ * Returns:
+ * {Object} the active layer
*/
getActiveLayer: function() {
return this.oActiveLayer;
},
/**
+ * Function: _addWorker
+ *
* indicate that a new asynchronous process has started and make sure the
* visual indicator is visible for the user. This is intended to be used
* internally by gMap but could be used by external tools if appropriate.
@@ -575,6 +764,8 @@
},
/**
+ * Function: _removeWorker
+ *
* indicate that an asynchronous process has completed and hide the
* visual indicator if no remaining processes are active. This is
* intended to be used internally by gMap but could be used by
@@ -589,19 +780,57 @@
this.triggerEvent(Fusion.Event.MAP_BUSY_CHANGED, this);
},
+ /**
+ * Function: mapExtentsChanged
+ *
+ * OpenLayers event handler for whenever the map changes either zoom level
+ * of the center has changed. This in turn triggers the Fusion event.
+ *
+ * Parameters: none
+ *
+ * Return: none
+ */
mapExtentsChanged: function() {
this._oCurrentExtents = this.oMapOL.getExtent();
this.triggerEvent(Fusion.Event.MAP_EXTENTS_CHANGED);
},
+ /**
+ * Function: isBusy
+ *
+ * check to see if there are any outstanding requests to the server
+ *
+ * Parameters: none
+ *
+ * Return: {Boolean} true if there are active requests
+ */
isBusy: function() {
return this._nWorkers > 0;
},
+ /**
+ * Function: sizeChanged
+ *
+ * callback for when the browser window size changes, simply calls resize
+ * on the map viewport layout object
+ *
+ * Parameters: none
+ *
+ * Return: none
+ */
sizeChanged: function() {
this.resize();
},
+ /**
+ * Function: resize
+ *
+ * handles the resizing of the maps and triggers a Fusion event
+ *
+ * Parameters: none
+ *
+ * Return: none
+ */
resize: function() {
if (!this.mapsLoaded) {
return;
@@ -609,29 +838,57 @@
//console.log('Fusion.Widget.Map.resize');
this.oMapOL.updateSize();
var d = $(this.getDomObj()).getContentBoxSize();
- this._nWidth = d.width;
- this._nHeight = d.height;
if (this._oCurrentExtents) {
this.setExtents(this._oCurrentExtents);
}
this.triggerEvent(Fusion.Event.MAP_RESIZED, this);
},
+ /**
+ * Function: redraw
+ *
+ * redraws the map using current extents and zoom level. A dummy parameter
+ * is added to the map request to ensure the map request is not cached.
+ *
+ * Parameters: none
+ *
+ * Return: none
+ */
redraw: function() {
for (var i=0; i<this.aMaps.length; i++ ) {
- if(this.aMaps[i].oLayerOL.params){
+ if(this.aMaps[i].oLayerOL.params){
this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
//mergeNewParams calls redraw on the layer, which will get called below anyway
//this.aMaps[i].oLayerOL.mergeNewParams({ts : (new Date()).getTime()});
- }
+ }
}
this.oMapOL.setCenter(this.oMapOL.getCenter(), this.oMapOL.getZoom(), false, true);
},
+ /**
+ * Function: setBackgroundColor
+ *
+ * sets the background color for the map
+ *
+ * Parameters: {String} color - the CSS color value to set as background
+ *
+ * Return: none
+ */
setBackgroundColor: function(color) {
this._oDomObj.style.backgroundColor = color;
},
+ /**
+ * Function: setExtents
+ *
+ * handle selection events from maps and republish for
+ * widgets as appropriate
+ *
+ * Parameters: {Object} oExtents - an OpenLayers.Bounds object or an array
+ * of 4 values that will be converted to Bounds
+ *
+ * Return: none
+ */
setExtents: function(oExtents) {
if (!oExtents) {
Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
@@ -652,10 +909,14 @@
},
/**
+ * Function: setInitialExtents
+ *
* determine the initialExtents of the map from (in order of precedence):
* 1. a URL query parameter called 'extent'
* 2. an <InitialView> specified in the MapGroup in AppDef
* 3. the maxExtent as specified by the LoadMap call (default)
+ *
+ * Returns: {Object} an OpenLayers.Bounds object which is the initial extent
*/
setInitialExtents: function() {
var initialExtents;
@@ -684,7 +945,12 @@
},
/**
- * sets the extent by examining all mapgroup map extents
+ * Function: getMapGroupExtent
+ *
+ * gets the intitial extents from all maps with or without including the
+ * extent of any Generic/commercial layers
+ *
+ * Return: {Object} an OpenLayers.Bounds object which is the initial extent
*/
getMapGroupExtent: function(includeGenericLayers) {
var initialExtent;
@@ -698,6 +964,8 @@
},
/**
+ * Function: fullExtents
+ *
* sets the extent of the map to the max as returned by loadMap
*/
fullExtents: function() {
@@ -705,10 +973,34 @@
this.setExtents(extents);
},
+ /**
+ * Function: isMapLoaded
+ *
+ * returns if the map has finished loading (based on setting the
+ * _oCurrentExtent value)
+ *
+ * Returns {Boolean} true if the map is loaded and extent has been set
+ */
isMapLoaded: function() {
return (this._oCurrentExtents) ? true : false;
},
+ /**
+ * Function: zoom
+ *
+ * sets the map zoom and extent.
+ *
+ * Parameters:
+ * fX {Float} - new x coordinate value in map units
+ * fY {Float} - new y coordinate value in map units
+ * nFactor {Float} - zoom factor; positive values zoom in, negative out
+ * - if set to 0 or 1, the map is just recentered
+ * - if the map has fractional zoom enabled, the map resolution
+ * will be modified by this factor
+ * - with fixed scales, zoom up or down one level, depending on the sign
+ *
+ * Returns: none
+ */
zoom: function(fX, fY, nFactor) {
//do this differntly with OL code??
if (nFactor == 1 || nFactor == 0) {
@@ -745,15 +1037,63 @@
}
},
+ /**
+ * Function: zoom
+ *
+ * sets the map zoom and extent.
+ *
+ * Parameters:
+ * fX {Float} - new x coordinate value in map units
+ * fY {Float} - new y coordinate value in map units
+ * nFactor {Float} - zoom factor; positive values zoom in, negative out
+ * - if set to 0 or 1, the map is just recentered
+ * - if the map has fractional zoom enabled, the map resolution
+ * will be modified by this factor
+ * - with fixed scales, zoom up or down one level, depending on the sign
+ *
+ * Returns: none
+ */
zoomToScale: function(fScale) {
var center = this.getCurrentCenter();
var extent = this.getExtentFromPoint(center.x, center.y, fScale);
this.setExtents(extent);
},
- queryRect : function(fMinX, fMinY, fMaxX, fMaxY) { },
+ /**
+ * Function: zoom
+ *
+ * sets the map zoom and extent.
+ *
+ * Parameters:
+ * fX {Float} - new x coordinate value in map units
+ * fY {Float} - new y coordinate value in map units
+ * nFactor {Float} - zoom factor; positive values zoom in, negative out
+ * - if set to 0 or 1, the map is just recentered
+ * - if the map has fractional zoom enabled, the map resolution
+ * will be modified by this factor
+ * - with fixed scales, zoom up or down one level, depending on the sign
+ *
+ * Returns: none
+ */
+ queryRect: function(fMinX, fMinY, fMaxX, fMaxY) { },
- queryPoint : function(fX, fY) { },
+ /**
+ * Function: zoom
+ *
+ * sets the map zoom and extent.
+ *
+ * Parameters:
+ * fX {Float} - new x coordinate value in map units
+ * fY {Float} - new y coordinate value in map units
+ * nFactor {Float} - zoom factor; positive values zoom in, negative out
+ * - if set to 0 or 1, the map is just recentered
+ * - if the map has fractional zoom enabled, the map resolution
+ * will be modified by this factor
+ * - with fixed scales, zoom up or down one level, depending on the sign
+ *
+ * Returns: none
+ */
+ queryPoint: function(fX, fY) { },
/**
*
@@ -765,7 +1105,7 @@
* @return an object with geographic coordinates in x and y properties of the
* object.
*/
- pixToGeo : function( pX, pY ) {
+ pixToGeo: function( pX, pY ) {
var lonLat = this.oMapOL.getLonLatFromPixel( new OpenLayers.Pixel(pX,pY) );
if (lonLat != null) {
return {x:lonLat.lon, y:lonLat.lat};
@@ -783,7 +1123,7 @@
* @return an object with pixel coordinates in x and y properties of the
* object.
*/
- geoToPix : function( gX, gY ) {
+ geoToPix: function( gX, gY ) {
if (!(this._oCurrentExtents)) {
return null;
}
@@ -799,7 +1139,7 @@
*
* @return geographic measure
*/
- pixToGeoMeasure : function(nPixels) {
+ pixToGeoMeasure: function(nPixels) {
var resolution = this.oMapOL.getResolution();
return (nPixels*resolution);
},
Modified: trunk/widgets/MapMenu.js
===================================================================
--- trunk/widgets/MapMenu.js 2010-03-11 05:38:18 UTC (rev 2097)
+++ trunk/widgets/MapMenu.js 2010-03-15 19:51:13 UTC (rev 2098)
@@ -157,8 +157,17 @@
//change the map, preserving current extents
switchMap: function(data) {
var ce = this.getMap().getCurrentExtents();
- var dest = new OpenLayers.Projection(data.maps[0].projCode);
- ce = ce.transform(this.oMap.oMapOL.baseLayer.projection, dest);
+ var dest = null;
+ for (var i=0; i<data.maps.length; ++i) {
+ if (data.maps[i].layerOptions.isBaseLayer) {
+ dest = new OpenLayers.Projection(data.maps[i].layerOptions.projection);
+ break;
+ }
+ }
+ if (!dest) {
+ dest = new OpenLayers.Projection("EPSG:4326");
+ }
+ ce = ce.transform(this.oMap.oMapOL.getProjectionObject(), dest);
data.initialView = {minX:ce.left,
minY:ce.bottom,
maxX:ce.right,
More information about the fusion-commits
mailing list