[fusion-commits] r1675 - trunk/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Nov 19 12:56:45 EST 2008
Author: chrisclaydon
Date: 2008-11-19 12:56:45 -0500 (Wed, 19 Nov 2008)
New Revision: 1675
Modified:
trunk/lib/Map.js
Log:
Ref #165 - Comment out the changes from submission 1659.
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2008-11-19 17:55:11 UTC (rev 1674)
+++ trunk/lib/Map.js 2008-11-19 17:56:45 UTC (rev 1675)
@@ -24,7 +24,7 @@
*/
/****************************************************************************
- * Class: Fusion.Widget.Map
+ * Class: Fusion.Widget.Map
*
* generic class for map widgets. Provides common utility classes.
* **********************************************************************/
@@ -54,7 +54,7 @@
_sDomObj: '',
_sMapname: '',
_nWidth: -1,
- _nHeight: -1,
+ _nHeight: -1,
_fMetersperunit: -1,
_fScale: -1,
_nDpi: 96,
@@ -63,16 +63,16 @@
_nWorkers: 0,
oContextMenu: null,
bSupressContextMenu: false,
-
+
aMaps: null,
mapsLoaded: false,
layerRoot: null,
singleTile: true,
fractionalZoom: true,
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.
+ * construct a new view Fusion.Widget.Map class.
*/
initialize : function(widgetTag, mapGroup, widgetSet) {
this.widgetTag = widgetTag;
@@ -89,37 +89,37 @@
groupName: 'mapRoot',
visible: true
});
-
+
var jxl = this._oDomObj.retrieve('jxLayout');
if (jxl) {
jxl.addEvent('sizeChange', OpenLayers.Function.bind(this.sizeChanged, this));
}
-
+
if (widgetTag.extension.FractionalZoom) {
this.fractionalZoom = widgetTag.extension.FractionalZoom[0]=='false'?false:true;
}
-
+
var scalesArray = null;
if (widgetTag.extension.Scales) {
scalesArray = widgetTag.extension.Scales[0].split(',');
this.fractionalZoom = false;
}
-
+
//Set a MaxScale in MapWIdget extension to allow zoom out to that scale
//otherwise, MaxScale is calculated automatically
if (widgetTag.extension.MaxScale) {
this.maxScale = parseInt(widgetTag.extension.MaxExtent[0]);
}
-
+
var maxExtent = null;
if (widgetTag.extension.MaxExtent) {
maxExtent = OpenLayers.Bounds.fromString(widgetTag.extension.MaxExtent[0]);
}
-
+
OpenLayers.DOTS_PER_INCH = this._nDpi;
if (!this.oMapOL) {
var options = {
- controls: [],
+ controls: [],
fallThrough: true,
scales: scalesArray,
fractionalZoom: this.fractionalZoom
@@ -133,27 +133,27 @@
}
this.oMapOL = new OpenLayers.Map(this._sDomObj, options );
}
-
+
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
-
+
this.handlers = [];
-
+
//add in the handler for mouse wheel actions
var useMouseWheel = true;
- if (widgetTag.extension.DisableMouseWheel &&
+ if (widgetTag.extension.DisableMouseWheel &&
widgetTag.extension.DisableMouseWheel[0] == 'true') {
useMouseWheel = false;
}
if (useMouseWheel) {
- this.wheelHandler = new OpenLayers.Handler.MouseWheel(this,
+ this.wheelHandler = new OpenLayers.Handler.MouseWheel(this,
{"up" : this.wheelUp,
"down": this.wheelDown} );
this.wheelHandler.map = this.oMapOL;
this.wheelHandler.activate();
this.handlers.push(this.wheelHandler);
}
-
+
$(name).widget = this;
this.registerEventID(Fusion.Event.MAP_EXTENTS_CHANGED);
@@ -166,29 +166,29 @@
this.registerEventID(Fusion.Event.MAP_RELOADED);
this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
-
+
this.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded,this));
-
+
//register for OL map extent change events
this.oMapOL.events.register('moveend', this, this.mapExtentsChanged);
-
+
this._oDomObj.onselectstart = function() {return false;};
this._oDomObj.oncontextmenu = function() {return false;};
- OpenLayers.Event.observe(this._oDomObj, 'contextmenu',
+ OpenLayers.Event.observe(this._oDomObj, 'contextmenu',
OpenLayers.Function.bind(this.onContextMenu, this));
-
+
this.aSelectionCallbacks = [];
this.bFetchingSelection = false;
-
+
//create the 'Map' layer widgets defined in the MapGroup
this.loadMapGroup(mapGroup);
},
-
+
mapLoaded: function() {
this.setViewOptions(this.getUnits());
},
-
- setMenu: function() {
+
+ setMenu: function() {
if (this.widgetTag.extension.MenuContainer) {
var contextMenu = new Jx.Menu.Context();
var container = this.widgetSet.getContainerByName(this.widgetTag.extension.MenuContainer[0]);
@@ -198,26 +198,26 @@
}
}
},
-
+
loadMapGroup: function(mapGroup) {
//clear any existing selection
this.mapsLoaded = false;
this.clearSelection();
//this._addWorker();
-
+
this.mapGroup = mapGroup;
for (var i=0; i<this.aMaps.length; i++) {
if (this.aMaps[i].oLayerOL) {
this.aMaps[i].oLayerOL.destroy();
}
}
-
+
this.aMaps = [];
this.layerRoot.clear();
-
+
for (var i=0; i<mapGroup.maps.length; ++i) {
var mapTag = mapGroup.maps[i];
-
+
if (Fusion.Layers[mapTag.type]) {
this.aMaps[i] = new Fusion.Layers[mapTag.type](this, mapTag, true);
this.layerRoot.addGroup(this.aMaps[i].layerRoot);
@@ -229,7 +229,7 @@
this.aMaps[i].registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.layerLoaded,this));
}
},
-
+
layerLoaded: function() {
for (var i=0; i<this.aMaps.length; ++i) {
if (!this.aMaps[i].isMapLoaded()) {
@@ -244,9 +244,9 @@
this.setExtents(initialExtent);
this.triggerEvent(Fusion.Event.MAP_LOADED);
},
-
+
/**
- * Method: wheelChange
+ * Method: wheelChange
*
* Parameters:
* evt - {Event}
@@ -255,7 +255,7 @@
var size = this.oMapOL.getSize();
var deltaX = size.w/2 - evt.xy.x;
var deltaY = evt.xy.y - size.h/2;
-
+
var deltaRes = deltaZ > 0 ? 0.5 : 2; //TODO: use some sort of factor here
var newRes = this.oMapOL.baseLayer.getResolution()*deltaRes;
var zoomPoint = this.oMapOL.getLonLatFromPixel(evt.xy);
@@ -267,67 +267,67 @@
newCenter.lat - size.h*newRes/2,
newCenter.lon + size.w*newRes/2,
newCenter.lat + size.h*newRes/2);
- this.wheelDelay = null;
+ //this.wheelDelay = null;
this.setExtents(newBounds);
},
- /**
+ /**
* Method: wheelUp
* User spun scroll wheel up
- *
+ *
* Parameters:
* evt - {Event}
*/
wheelUp: function(evt) {
- if (this.wheelDelay) {
- window.clearTimeout(this.wheelDelay);
- }
- this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, 1),200);
- // this.wheelChange(evt, 1);
+ //if (this.wheelDelay) {
+ // window.clearTimeout(this.wheelDelay);
+ //}
+ //this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, 1),200);
+ this.wheelChange(evt, 1);
},
- /**
+ /**
* Method: wheelDown
* User spun scroll wheel down
- *
+ *
* Parameters:
* evt - {Event}
*/
wheelDown: function(evt) {
- if (this.wheelDelay) {
- window.clearTimeout(this.wheelDelay);
- }
- this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, -1),200);
- // this.wheelChange(evt, -1);
+ //if (this.wheelDelay) {
+ // window.clearTimeout(this.wheelDelay);
+ //}
+ //this.wheelDelay = window.setTimeout(OpenLayers.Function.bind(this.wheelChange, this, evt, -1),200);
+ this.wheelChange(evt, -1);
},
/**
- * returns the dom element
+ * returns the dom element
*/
getDomObj: function() {
return this._oDomObj;
},
- getMapName: function() {
+ 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();
},
- getMapTitle: function() {
+ 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;
},
- getSessionID: function() {
+ 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();
},
- getDomId: function() {
+ getDomId: function() {
return this._sDomObj;
},
@@ -336,21 +336,21 @@
},
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,
+ units: map.units,
projection: this.projection
});
}
-
+
//if bRestrictExtent is null, use the default OL behaviour with somewhat restricted map navigation
//if bRestrictExtent is set to true, map navigation is limited to the map extent
- //if bRestrictExtent is set to false, map navigation is not restricted at all
+ //if bRestrictExtent is set to false, map navigation is not restricted at all
if (this.bRestrictExtent != null) {
if (this.bRestrictExtent) {
this.oMapOL.restrictedExtent = map.mapTag.layerOptions.maxExtent;
@@ -360,18 +360,18 @@
}
this.oMapOL.addLayer(map.oLayerOL);
console.log('layer added:'+map.oLayerOL.name);
- map.registerForEvent(Fusion.Event.MAP_LOADED,
+ map.registerForEvent(Fusion.Event.MAP_LOADED,
OpenLayers.Function.bind(this.mapLoadHandler, this));
- map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
+ map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
OpenLayers.Function.bind(this.selectionHandler, this));
- map.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
+ map.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
OpenLayers.Function.bind(this.selectionHandler, this));
},
getAllMaps: function() {
return this.aMaps;
},
-
+
//this uses setTimeout so this method can be called from an IFRAME
reloadMap: function() {
for (var i=0; i<this.aMaps.length; ++i) {
@@ -379,7 +379,7 @@
window.setTimeout(OpenLayers.Function.bind(map.reloadMap, map),1);
}
},
-
+
loadScaleRanges: function(userFunc) {
for (var i=0; i<this.aMaps.length; ++i) {
var map = this.aMaps[i];
@@ -398,7 +398,7 @@
}
}
},
-
+
/**
* Function: mapLoadHandler
*
@@ -413,7 +413,7 @@
this.triggerEvent(Fusion.Event.MAP_LOADED);
}
},
-
+
/**
* Function: selectionHandler
*
@@ -427,7 +427,7 @@
this.triggerEvent(Fusion.Event.MAP_SELECTION_OFF);
}
},
-
+
/**
* Function: hasSelection
*
@@ -441,7 +441,7 @@
}
return false;
},
-
+
/**
* Function: clearSelection
*
@@ -453,7 +453,7 @@
this.aMaps[i].clearSelection();
}
},
-
+
/**
* Function: getSelection
*
@@ -474,8 +474,8 @@
this.nSelectionMaps = 0;
for (var i=0; i<this.aMaps.length; i++ ) {
this.nSelectionMaps++;
- this.aMaps[i].getSelection(
- OpenLayers.Function.bind(this.accumulateSelection, this, this.aMaps[i]),
+ this.aMaps[i].getSelection(
+ OpenLayers.Function.bind(this.accumulateSelection, this, this.aMaps[i]),
layers, startcount);
}
},
@@ -499,7 +499,7 @@
*/
accumulateSelection: function(map, oSelection) {
this.oSelection[map._sMapname] = oSelection;
-
+
if (!--this.nSelectionMaps) {
this.bFetchingSelection = false;
for (var i=0; i<this.aSelectionCallbacks.length; i++) {
@@ -539,13 +539,13 @@
_addWorker: function() {
this._nWorkers += 1;
this.triggerEvent(Fusion.Event.MAP_BUSY_CHANGED, this);
- this._oDomObj.style.cursor = 'wait';
+ this._oDomObj.style.cursor = 'wait';
},
/**
* 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
+ * visual indicator if no remaining processes are active. This is
+ * intended to be used internally by gMap but could be used by
* external tools if appropriate. Only call this function if
* addWorker was previously called
*/
@@ -556,7 +556,7 @@
this.setCursor(this.cursor);
this.triggerEvent(Fusion.Event.MAP_BUSY_CHANGED, this);
},
-
+
mapExtentsChanged: function() {
this._oCurrentExtents = this.oMapOL.getExtent();
this.triggerEvent(Fusion.Event.MAP_EXTENTS_CHANGED);
@@ -569,7 +569,7 @@
sizeChanged: function() {
this.resize();
},
-
+
resize: function() {
if (!this.mapsLoaded) {
return;
@@ -584,7 +584,7 @@
}
this.triggerEvent(Fusion.Event.MAP_RESIZED, this);
},
-
+
redraw: function() {
for (var i=0; i<this.aMaps.length; i++ ) {
this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
@@ -593,20 +593,20 @@
}
this.oMapOL.setCenter(this.oMapOL.getCenter(), this.oMapOL.getZoom(), false, true);
},
-
+
setBackgroundColor: function(color) {
this._oDomObj.style.backgroundColor = color;
},
-
+
setExtents: function(oExtents) {
if (!oExtents) {
- Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
+ Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
OpenLayers.i18n('nullExtents')));
}
if (oExtents instanceof Array && oExtents.length == 4) {
oExtents = new OpenLayers.Bounds(oExtents[0], oExtents[1], oExtents[2], oExtents[3]);
}
-
+
//update the timestamp param to prevent caching
for (var i=0; i<this.aMaps.length; i++ ) {
if (this.aMaps[i].oLayerOL.params && this.aMaps[i].noCache) {
@@ -631,7 +631,7 @@
} else if (this.mapGroup.initialView) {
var iv = this.mapGroup.getInitialView();
if (iv.x) {
- initialExtents = this.getExtentFromPoint(iv.x, iv.y, iv.scale);
+ initialExtents = this.getExtentFromPoint(iv.x, iv.y, iv.scale);
} else if (iv.minX) {
initialExtents = new OpenLayers.Bounds(iv.minX, iv.minY, iv.maxX, iv.maxY);
}
@@ -646,7 +646,7 @@
}
}
this.initialExtents = initialExtents;
- return initialExtents;
+ return initialExtents;
},
/**
@@ -654,7 +654,7 @@
*/
fullExtents: function() {
var extents = this.maxExtent;
- this.setExtents(extents);
+ this.setExtents(extents);
},
isMapLoaded: function() {
@@ -694,19 +694,19 @@
this.oMapOL.zoomTo(currentZoomLevel-1);
}
}
- }
+ }
},
-
+
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) { },
-
+
queryPoint : function(fX, fY) { },
-
+
/**
*
* convert pixel coordinates into geographic coordinates.
@@ -714,13 +714,13 @@
* @paran pX int the x coordinate in pixel units
* @param pY int the y coordinate in pixel units
*
- * @return an object with geographic coordinates in x and y properties of the
+ * @return an object with geographic coordinates in x and y properties of the
* object.
*/
pixToGeo : function( pX, pY ) {
var lonLat = this.oMapOL.getLonLatFromPixel( new OpenLayers.Pixel(pX,pY) );
if (lonLat != null) {
- return {x:lonLat.lon, y:lonLat.lat};
+ return {x:lonLat.lon, y:lonLat.lat};
}
return null;
},
@@ -732,7 +732,7 @@
* @paran gX int the x coordinate in geographic units
* @param gY int the y coordinate in geographic units
*
- * @return an object with pixel coordinates in x and y properties of the
+ * @return an object with pixel coordinates in x and y properties of the
* object.
*/
geoToPix : function( gX, gY ) {
@@ -755,10 +755,10 @@
var resolution = this.oMapOL.getResolution();
return (nPixels*resolution);
},
-
+
/**
*
- * initializes the meters per unit values when a new map is loaded. Some systems make different
+ * initializes the meters per unit values when a new map is loaded. Some systems make different
* assumptions for the conversion of degrees to meters so this makes sure both Fusion and
* OpenLayers are using the same value.
*
@@ -770,12 +770,12 @@
this._fMetersperunit = metersPerUnit;
} else {
if (metersPerUnit != this._fMetersperunit) {
- Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
+ Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
'meters per unit value already set'));
}
}
},
-
+
/**
*
* returns the meters per unit value
@@ -785,7 +785,7 @@
getMetersPerUnit: function() {
return this._fMetersperunit;
},
-
+
/**
*
* initializes all widgets with the map units after the map has loaded
@@ -794,7 +794,7 @@
setViewOptions: function(data) {
this.setWidgetParam('Units', data);
},
-
+
/**
*
* initializes all widgets with a parameter and value at runtime
@@ -813,7 +813,7 @@
}
}
},
-
+
/**
*
* convert geographic into pixels.
@@ -825,7 +825,7 @@
geoToPixMeasure: function(fGeo) {
return parseInt(fGeo/this.oMapOL.getResolution());
},
-
+
/**
* Function: getCurrentCenter
*
@@ -859,7 +859,7 @@
if (!fScale) {
fScale = this.getScale();
}
-
+
var res = OpenLayers.Util.getResolutionFromScale(fScale, this.oMapOL.baseLayer.units);
var size = this.getSize();
var w_deg = size.w * res;
@@ -869,19 +869,19 @@
fX + w_deg / 2,
fY + h_deg / 2);
},
-
+
getScale: function() {
return this.oMapOL.getScale();
},
-
+
getResolution: function() {
return this.oMapOL.getResolution();
},
-
+
getUnits: function() {
return this.oMapOL.baseLayer.units;
},
-
+
getSize: function() {
return this.oMapOL.getSize();
},
@@ -905,7 +905,7 @@
} else if (typeof cursor == 'string') {
this._oDomObj.style.cursor = cursor;
} else {
- this._oDomObj.style.cursor = 'auto';
+ this._oDomObj.style.cursor = 'auto';
}
},
/**
@@ -970,22 +970,22 @@
//oWidget.deactivate();
//this.oActiveWidget = null;
},
-
+
/**
*/
isLoaded: function() {
return (this.oMapOL.getExtent() != null);
},
-
+
supressContextMenu: function( bSupress ) {
this.bSupressContextMenu = bSupress;
},
-
+
setContextMenu: function(menu) {
//console.log('setcontextmenu');
this.oContextMenu = menu;
},
-
+
onContextMenu: function(e) {
//console.log('oncontextmenu');
if (this.oContextMenu && !this.bSupressContextMenu && this.isLoaded()) {
@@ -994,7 +994,7 @@
OpenLayers.Event.stop(e);
}
},
-
+
executeFromContextMenu: function(widget) {
//console.log('executefromcontextmenu');
widget.activate(this.contextMenuPosition.x, this.contextMenuPosition.y);
@@ -1011,7 +1011,7 @@
Fusion.SelectionObject = OpenLayers.Class({
aLayers : null,
- initialize: function(o)
+ initialize: function(o)
{
this.aLayers = [];
this.nTotalElements =0;
@@ -1023,7 +1023,7 @@
this.fMinY = o.extents.miny;
this.fMaxX = o.extents.maxx;
this.fMaxY = o.extents.maxy;
-
+
this.nLayers = o.layers.length;
for (var i=0; i<o.layers.length; i++)
{
@@ -1051,7 +1051,7 @@
{
return this.nLayers;
},
-
+
getLayerByName : function(name)
{
var oLayer = null;
@@ -1077,7 +1077,7 @@
{
return null;
}
-
+
}
});
@@ -1095,8 +1095,8 @@
distance: null,
bbox: null,
center: null,
-
- initialize: function(o, layerName)
+
+ initialize: function(o, layerName)
{
this.name = layerName;
this.nElements = o[layerName].numelements;
@@ -1110,12 +1110,12 @@
this.aPropertiesTypes = [];
this.aPropertiesTypes = o[layerName].propertytypes;
-
+
//var oValueCollection = oNode.findNextNode('ValueCollection');
-
+
this.area = 0;
this.distance = 0;
-
+
for (var i=0; i<o[layerName].values.length; i++)
{
this.aElements[i] =[];
@@ -1124,7 +1124,7 @@
this.aElements[i][j] = o[layerName].values[i][j];
}
}
-
+
//loop over all features in the metadata array
for (var i=0; i<o[layerName].metadata.length; i++) {
var featureMetadata = o[layerName].metadata[i];
@@ -1136,24 +1136,24 @@
this.area += parseFloat(area);
this.distance += parseFloat(length);
}
-
+
/*
var iElement=0;
- while(oValueCollection)
+ while(oValueCollection)
{
this.aElements[iElement] = [];
for (var i=0; i<oValueCollection.childNodes.length; i++)
{
oTmp = oValueCollection.childNodes[i].findFirstNode('v');
this.aElements[iElement][i] = oTmp.textContent;
-
+
}
var type = oValueCollection.attributes['type'];
var area = oValueCollection.attributes['area'];
var distance = oValueCollection.attributes['distance'];
var bbox = oValueCollection.attributes['bbox'];
var center = oValueCollection.attributes['center'];
-
+
this.aElements[iElement]['attributes'] = {};
this.aElements[iElement]['attributes'].type = type;
this.aElements[iElement]['attributes'].bbox = bbox;
@@ -1173,7 +1173,7 @@
*/
//console.log( 'final area is ' + this.area);
//console.log( 'final distance is ' + this.distance);
-
+
},
getName : function()
More information about the fusion-commits
mailing list