[fusion-commits] r2313 - in trunk: layers lib widgets widgets/Maptip
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Jan 7 15:36:04 EST 2011
Author: madair
Date: 2011-01-07 12:36:04 -0800 (Fri, 07 Jan 2011)
New Revision: 2313
Removed:
trunk/widgets/Maptip/Maptip.php
Modified:
trunk/layers/Layers.js
trunk/lib/ApplicationDefinition.js
trunk/lib/Widget.js
trunk/widgets/Buffer.js
trunk/widgets/BufferPanel.js
trunk/widgets/FeatureInfo.js
trunk/widgets/Help.js
trunk/widgets/InvokeURL.js
trunk/widgets/LayerManager.js
trunk/widgets/Legend.js
trunk/widgets/MapMetadata.js
trunk/widgets/Maptip.js
trunk/widgets/Measure.js
trunk/widgets/Print.js
trunk/widgets/Query.js
trunk/widgets/QuickPlot.js
trunk/widgets/SaveMap.js
trunk/widgets/Search.js
trunk/widgets/SelectAttribute.js
trunk/widgets/SelectRadius.js
trunk/widgets/SelectRadiusValue.js
trunk/widgets/SelectWithin.js
trunk/widgets/SelectionPanel.js
trunk/widgets/TaskPane.js
trunk/widgets/Theme.js
trunk/widgets/ZoomToSelection.js
Log:
re #426: widgets can now be associated with a particular <Map> through an id attribute and a <WidgetLayerId> element in the widget's extension.
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/layers/Layers.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -92,6 +92,7 @@
this.sMapResourceId = mapTag.resourceId ? mapTag.resourceId : '';
this.mapInfo = mapTag.mapInfo;
this.layerType = mapTag.type;
+ this.id = mapTag.id;
},
/**
Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/lib/ApplicationDefinition.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -489,6 +489,7 @@
initialize: function(jsonNode) {
/* TODO: type can be any supported OpenLayers type */
+ this.id = jsonNode['@id'] ? jsonNode['@id'][0] : null;
this.type = jsonNode.Type[0];
if (jsonNode.SingleTile) {
var b = jsonNode.SingleTile[0].toLowerCase();
Modified: trunk/lib/Widget.js
===================================================================
--- trunk/lib/Widget.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/lib/Widget.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -38,6 +38,7 @@
name: null,
type: null,
oMap: null,
+ widgetLayerId: null, //the AppDef <Map> object associated with this widget
enabled: false,
mapLoadedWatcher: null,
paramRegister: null,
@@ -75,6 +76,10 @@
this.paramRegister = [];
+ //check to see if this widget is associated with a specific Map
+ var json = widgetTag.extension;
+ this.widgetLayerId = json.WidgetLayerId ? json.WidgetLayerId[0] : null;
+
this.initializeWidget(widgetTag);
},
@@ -185,6 +190,25 @@
},
/**
+ * accessor to get the Map object that this widget is associated with
+ * @return {object} the map
+ */
+ getMapLayer: function() {
+ if (this.widgetLayerId) {
+ var map = this.getMap();
+ for (var i=0; i<map.aMaps.length; ++i) {
+ if (map.aMaps[i].id && (map.aMaps[i].id == this.widgetLayerId) ) {
+ return map.aMaps[i];
+ }
+ }
+ Fusion.reportError("Requested widgetLayerId not found:"+this.widgetLayerId);
+ return null;
+ } else {
+ return this.getMap().aMaps[0];
+ }
+ },
+
+ /**
* utility method to add an OL control to the OL map object
*/
addControl: function(control) {
Modified: trunk/widgets/Buffer.js
===================================================================
--- trunk/widgets/Buffer.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Buffer.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -202,25 +202,25 @@
}
var mapWidget = this.getMap();
- var aMaps = mapWidget.getAllMaps();
- var s = aMaps[0].arch + '/' + Fusion.getScriptLanguage() + "/Buffer." + Fusion.getScriptLanguage();
+ var widgetLayer = this.getMapLayer();
+ var s = widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/Buffer." + Fusion.getScriptLanguage();
var params = {};
params.parameters = 'locale='+Fusion.locale +
'&merge=1' +
- '&session='+aMaps[0].getSessionID() +
- '&mapname='+ aMaps[0].getMapName()+
+ '&session='+widgetLayer.getSessionID() +
+ '&mapname='+ widgetLayer.getMapName()+
layer+distance+borderColor+fillColor;
params.onComplete = OpenLayers.Function.bind(this.bufferCreated, this);
Fusion.ajaxRequest(s, params);
},
bufferCreated: function() {
- var aMaps = this.getMap().getAllMaps();
- var layer = aMaps[0].getLayerByName(this.layerName);
+ var widgetLayer = this.getMapLayer();
+ var layer = widgetLayer.getLayerByName(this.layerName);
if (layer) {
layer.noCache = true;
}
- aMaps[0].reloadMap();
- aMaps[0].drawMap();
+ widgetLayer.reloadMap();
+ widgetLayer.drawMap();
}
});
Modified: trunk/widgets/BufferPanel.js
===================================================================
--- trunk/widgets/BufferPanel.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/BufferPanel.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -95,14 +95,14 @@
//add in other parameters to the url here
var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('locale='+Fusion.locale);
- params.push('session='+mapLayers[0].getSessionID());
- params.push('mapname='+mapLayers[0].getMapName());
+ params.push('session='+widgetLayer.getSessionID());
+ params.push('mapname='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('popup=false');
} else {
Modified: trunk/widgets/FeatureInfo.js
===================================================================
--- trunk/widgets/FeatureInfo.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/FeatureInfo.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -38,7 +38,7 @@
Fusion.Widget.FeatureInfo = OpenLayers.Class(Fusion.Widget, {
isExclusive: true,
uiClass: Jx.Button,
- sFeatures : 'menubar=no,location=no,resizable=no,status=no',
+ sFeatures: 'menubar=no,location=no,resizable=no,status=no',
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
@@ -51,14 +51,14 @@
//add in other parameters to the url here
var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('LOCALE='+Fusion.locale);
- params.push('SESSION='+mapLayers[0].getSessionID());
- params.push('MAPNAME='+mapLayers[0].getMapName());
+ params.push('SESSION='+widgetLayer.getSessionID());
+ params.push('MAPNAME='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('POPUP=false');
} else {
Modified: trunk/widgets/Help.js
===================================================================
--- trunk/widgets/Help.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Help.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -69,7 +69,7 @@
activate: function() {
var url = this.baseUrl;
- var map = this.getMap();
+ var map = this.getMapLayer();
var params = [];
params.push('LOCALE='+Fusion.locale);
params.push('SESSION='+map.getSessionID());
Modified: trunk/widgets/InvokeURL.js
===================================================================
--- trunk/widgets/InvokeURL.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/InvokeURL.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -37,7 +37,7 @@
Fusion.Widget.InvokeURL = OpenLayers.Class(Fusion.Widget, {
uiClass: Jx.Button,
- sFeatures : 'menubar=no,location=no,resizable=no,status=no',
+ sFeatures: 'menubar=no,location=no,resizable=no,status=no',
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
@@ -66,10 +66,11 @@
enable: function() {
var map = this.getMap();
+ var widgetLayer = this.getMapLayer();
if (this.bSelectionOnly || !map) {
if (map && map.hasSelection()) {
- if (map.aMaps[0]._sQueryfile) {
- this.additionalParameters.push('queryfile='+map.aMaps[0]._sQueryfile);
+ if (widgetLayer._sQueryfile) {
+ this.additionalParameters.push('queryfile='+widgetLayer._sQueryfile);
}
if (this.action) {
this.action.setEnabled(true);
@@ -96,7 +97,7 @@
var url = this.sBaseUrl;
//add in other parameters to the url here
- var map = this.getMap();
+ var map = this.getMapLayer();
var params = [];
params.push('locale='+Fusion.locale);
params.push('session='+map.getSessionID());
Modified: trunk/widgets/LayerManager.js
===================================================================
--- trunk/widgets/LayerManager.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/LayerManager.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -71,7 +71,7 @@
this.map.registerForEvent(Fusion.Event.MAP_RELOADED, OpenLayers.Function.bind(this.mapReLoaded, this));
this.map.registerForEvent(Fusion.Event.MAP_SCALE_RANGE_LOADED, OpenLayers.Function.bind(this.scaleRangeLoaded, this));
// update changes to the legend in this widget
- this.map.aMaps[0].registerForEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, OpenLayers.Function.bind(this.layerChanged,this));
+ this.getMapLayer().registerForEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, OpenLayers.Function.bind(this.layerChanged,this));
},
scaleRangeLoaded: function() {
@@ -82,7 +82,7 @@
},
layerChanged: function(eventId, layer) {
- this.updateLayer(this.map.aMaps[0]);
+ this.updateLayer(this.getMapLayer());
this.updateSessionMapFile();
},
mapReLoaded: function(){
@@ -335,14 +335,11 @@
updateSessionMapFile: function(){
// console.log("updateSessionMapFile");
- // get map
- var map = this.getMap();
- var aMaps = map.getAllMaps();
- var currentMap = aMaps[0];
- var sessionId = aMaps[0].getSessionID();
+ var widgetLayer = this.getMapLayer();
+ var sessionId = widgetLayer.getSessionID();
// get all layers
- var oLayers = currentMap.aLayers;
+ var oLayers = widgetLayer.aLayers;
var aLayerNames = [];
var visibleLayers = [];
for(var i=0;i<oLayers.length;i++){
@@ -353,13 +350,12 @@
}
// prepare ajax req
- var params = '&session='+sessionId+'&mapname='+ this.getMap().getMapName()+'&visLayers='+visibleLayers+'&layers='+aLayerNames;
+ var params = '&session='+sessionId+'&mapname='+ widgetLayer.getMapName()+'&visLayers='+visibleLayers+'&layers='+aLayerNames;
var options = {parameters: params};
// fire the request no need to return
- var m = this.getMap().aMaps[0];
- var url = 'layers/' + m.arch + '/' + Fusion.getScriptLanguage() + "/updateSessionMapFile." + Fusion.getScriptLanguage()
- Fusion.ajaxRequest( url, options);
+ var url = 'layers/' + widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/updateSessionMapFile." + Fusion.getScriptLanguage()
+ Fusion.ajaxRequest(url, options);
}
});
Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Legend.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -381,7 +381,7 @@
mapLoaded: function() {
this.getMap().registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, this.extentsChangedWatcher);
- var baseLayer = this.getMap().aMaps[0];
+ var baseLayer = this.oLegend.getMapLayer();
baseLayer.registerForEvent(Fusion.Event.MAP_LAYER_ORDER_CHANGED, OpenLayers.Function.bind(this.mapRefresh, this));
this.layerRoot = this.getMap().layerRoot;
//this.renderLegend();
@@ -393,7 +393,7 @@
},
mapRefresh: function() {
- var baseLayer = this.getMap().aMaps[0];
+ var baseLayer = this.oLegend.getMapLayer();
baseLayer.parseLayers();
this.layerRoot = this.getMap().layerRoot;
this.renderLegend();
@@ -411,7 +411,7 @@
this.clear();
if (this.showRootFolder) {
- this.oRoot.setLabel(this.getMap().getMapTitle());
+ this.oRoot.setLabel(this.oLegend.getMapLayer().getMapTitle());
}
var startGroup = this.layerRoot;
if (!this.showMapFolder) {
Modified: trunk/widgets/MapMetadata.js
===================================================================
--- trunk/widgets/MapMetadata.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/MapMetadata.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -62,7 +62,8 @@
*
*/
showMetadata: function() {
- var metadata = this.getMap().getMetadata(this.metadataId);
+ var metadataLayer = this.getMapLayer();
+ var metadata = metadataLayer.getMetadata(this.metadataId);
if (metadata) {
//this.domObj.appendChild(metadata);
if (this.content == 'markup') {
Deleted: trunk/widgets/Maptip/Maptip.php
===================================================================
--- trunk/widgets/Maptip/Maptip.php 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Maptip/Maptip.php 2011-01-07 20:36:04 UTC (rev 2313)
@@ -1,358 +0,0 @@
-/**
- * Fusion.Widget.Maptip2
- *
- * $Id: $
- *
- * Portions copyright (c) 2007, DM Solutions Group Inc.
- * Portions copyright (c) 2008, ENPLAN
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
- /********************************************************************
- * Class: Fusion.Widget.Maptip
- *
- * Displays tooltips over the map when the mouse is hovered for some
- * time. On the MapGuide platform, you must configure tooltips for
- * each layer using Studio or Web Studio by editing the LayerDefinition
- * Settings and specifying an expression for the tooltip. MapServer users
- * can instead specify which attribute fields in the layer are to be used
- * for the maptip text and optional hyperlink.
- *
- *
- * Delay (optional)
- *
- * This is the delay, in milliseconds, that the user must keep the mouse
- * in the same position in order for the maptip to appear. The default,
- * if not specified, is 350 milliseconds.
- *
- * Layer
- *
- * -MapGuide(optional, multiple): This is the name of a layer from the MapDefinition
- * to get the tooltip from. If no Layer elements are specified, then all layers
- * will be queried and the top-most one will be displayed. Multiple Layer
- * tags can be added, allowing tooltips to come from different layers.
- *
- * -Mapserver(required): This is the name of a layer from the MapFile whose attributes
- * will be used to populate the maptip text. Mapserver only supports a single layer.
- * If more than one layer is specified, only the first will be used.
- *
- * Textfield (required for MapServer only)
- *
- * Field to use for the maptip text for MapServer-based Fusion installs.
- * Since this is not specified server-side, as in MapGuide, it must be
- * declared here.
- *
- * Linkfield (optional for MapServer only)
- *
- * Field to use for the maptip hyperlink target URL on MapServer fusion installs.
- * As with Textfield above, it must be declared here if needed.
- *
- * **********************************************************************/
-
-Fusion.Widget.Maptip2 = OpenLayers.Class(Fusion.Widget, {
- oCurrentPosition: null,
- oMapTipPosition: null,
- nTimer: null,
- delay: null,
- aLayers: null,
- bOverTip: false,
- textField: null,
- linkField: null,
- customURL: null,
- sWinFeatures : 'menubar=no,location=no,resizable=no,status=no',
-
- initializeWidget: function(widgetTag){
- // console.log("maptipStarted");
- // Object.inheritFrom(this, Fusion.Widget.prototype, [widgetTag, true]);
- var json = widgetTag.extension;
-
- this.sTarget = json.Target ? json.Target[0] : "MaptipWindow";
- if (json.WinFeatures) {
- this.sWinFeatures = json.WinFeatures[0];
- }
- this.delay = json.Delay ? parseInt(json.Delay[0]) : 350;
- this.nTolerance = json.Tolerance ? parseInt(json.Tolerance[0]) : 2;
-
- this.aLayers = [];
- if (json.Layer) {
- for (var i=0; i<json.Layer.length; i++) {
- this.aLayers.push(json.Layer[i]);
- }
- }
-
- this.customURL = json.CustomURL;
- this.textField = json.TextField;
- this.linkField = json.Linkfield;
-
- //prepare the container div for the maptips
- Fusion.addWidgetStyleSheet(widgetTag.location + 'Maptip/Maptip.css');
- if (this.domObj) {
- this.domObj.parentNode.removeChild(this.domObj);
- } else {
- this.domObj = document.createElement('div');
- }
- this.domObj.className = 'maptipContainer';
- this.domObj.style.display = 'none';
- this.domObj.style.top = '0px';
- this.domObj.style.left = '0px';
-
- //create an iframe to stick behind the maptip to prevent clicks being passed through to the map
- this.iframe = document.createElement('iframe');
- this.iframe.className = 'maptipShim';
- this.iframe.scrolling = 'no';
- this.iframe.frameborder = 0;
-
- OpenLayers.Event.observe(this.domObj, 'mouseover', OpenLayers.Function.bind(this.mouseOverTip, this));
- OpenLayers.Event.observe(this.domObj, 'mouseout', OpenLayers.Function.bind(this.mouseOutTip, this));
-
- var oDomElem = this.getMap().getDomObj();
- document.getElementsByTagName('BODY')[0].appendChild(this.domObj);
-
- this.getMap().observeEvent('mousemove', OpenLayers.Function.bind(this.mouseMove, this));
- this.getMap().observeEvent('mouseout', OpenLayers.Function.bind(this.mouseOut, this));
-
- },
-
- mouseOut: function(e) {
- //console.log('maptip mouseOut');
- if (this.nTimer) {
- window.clearTimeout(this.nTimer);
- if (!this.nHideTimer) {
- /*console.log('mouseOut: set hide timer');*/
- this.nHideTimer = window.setTimeout(this.hideMaptip.bind(this), 250);
- }
- }
- },
-
- mouseMove: function(e) {
- //console.log('map tip mouseMove');
- var map = this.getMap();
- var Map = map.aMaps[0];
- if (this.bOverTip) {
- return;
- }
- var p = this.getMap().getEventPosition(e);
- this.oCurrentPosition = p;
- this.oMapTipPosition = {x:e.xy.x, y:e.xy.y};
- if (this.oCurrentPosition) {
- window.clearTimeout(this.nTimer);
- this.nTimer = null;
- }
- //Bind to the appropriate function for the platform
- var showMaptip = this.showMaptip.bind(this)
-
- this.nTimer = window.setTimeout(showMaptip, this.delay);
- //Event.stop(e);
- },
- /*
- showMaptipMG: function(r) {
- //Gets the maptip data on MapGuide
- console.log('showMaptip');
- var map = this.getMap();
- if (map == null) {
- return;
- }
- var oBroker = Fusion.oBroker;
- var x = this.oCurrentPosition.x;
- var y = this.oCurrentPosition.y;
- var min = map.pixToGeo(x-this.nTolerance, y-this.nTolerance);
- var max = map.pixToGeo(x+this.nTolerance, y+this.nTolerance);
- //this can fail if no map is loaded
- if (!min) {
- return;
- }
- var sGeometry = 'POLYGON(('+ min.x + ' ' + min.y + ', ' + min.x + ' ' + max.y + ', ' + max.x + ' ' + max.y + ', ' + max.x + ' ' + min.y + ', ' + min.x + ' ' + min.y + '))';
- var maxFeatures = 1;
- var persist = 0;
- var selection = 'INTERSECTS';
- // only select visible layers with maptips defined (1+4)
- var layerAttributeFilter = 5;
- var maps = this.getMap().getAllMaps();
- //TODO: possibly make the layer names configurable?
- var layerNames = this.aLayers.toString();
- var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(maps[0].getSessionID(),
- maps[0]._sMapname,
- sGeometry,
- maxFeatures, persist, selection, layerNames,
- layerAttributeFilter);
- oBroker.dispatchRequest(r, this.parseMGXML.bind(this));
- },
-
- parseMGXML: function(r) {
- //Parses the XML returned by MG and passes the text & link values to the
- //mtDisplay function
- if (r) {
- var d = new DomNode(r);
- var t = d.getNodeText('Tooltip');
- var h = d.getNodeText('Hyperlink');
- var mtDisplayFunc = this.mtDisplay.bind(this);
- mtDisplayFunc(t,h);
- }
- },
- */
-
- showMaptip: function(r) {
- var pos = this.getMap().pixToGeo(this.oCurrentPosition.x, this.oCurrentPosition.y);
- //console.log(pos);
- var options = {};
- var dfGeoTolerance = this.getMap().pixToGeoMeasure(this.nTolerance);
- var minx = pos.x-dfGeoTolerance;
- var miny = pos.y-dfGeoTolerance;
- var maxx = pos.x+dfGeoTolerance;
- var maxy = pos.y+dfGeoTolerance;
- options.geometry = 'POLYGON(('+ minx + ' ' + miny + ', ' + minx + ' ' + maxy + ', ' + maxx + ' ' + maxy + ', ' + maxx + ' ' + miny + ', ' + minx + ' ' + miny + '))';
-
- options.selectionType = "INTERSECTS";
-
- if (this.bActiveOnly) {
- var layer = this.getMap().getActiveLayer();
- if (layer) {
- options.layers = layer.layerName;
- } else {
- return;
- }
- }
-
- var Map = this.getMap().aMaps[0];
- var bPersistant = options.persistent || true;
- var zoomTo = options.zoomTo ? true : false;
- var loadmapScript = '/layers/'+Map.arch + '/php/maptip.php';
- var params = {
- 'mapname': Map._sMapname,
- 'session': Map.getSessionID(),
- 'spatialfilter': options.geometry || '',
- 'maxfeatures': options.maxFeatures || 0, //zero means select all features
- 'variant': 'intersects',
- 'layer': this.aLayers[0] || '',
- 'textfield': this.textField || '',
- 'customURL': this.customURL || ''
- }
- var mtDisplayFunc = this.mtDisplay.bind(this);
- var ajaxOptions = {
- onSuccess: function(response){
- eval("rjson=" + response.responseText);
- mtDisplayFunc(rjson.mapTipText,rjson.mapTipLink);
- },
- parameters: params};
- Fusion.ajaxRequest(loadmapScript, ajaxOptions);
- },
-
- mtDisplay: function(t,h) {
- //console.log("t:" + t);
- //console.log("h:" + h);
-
- if (t !="") {
- this.domObj.innerHTML = ' ';
- var contentDiv = document.createElement('div');
- contentDiv.className = 'maptipContent';
- this.domObj.appendChild(contentDiv);
- var empty = true;
- this.bIsVisible = true;
- if (t != '') {
- t = t.replace(/\\n/g, "<br>");
- if (h != '') {
- var linkDiv = document.createElement('div');
- var a = document.createElement('a');
- a.innerHTML = t;
- a.href = 'javascript:void(0)';
- a.url = h;
- a.onclick = this.openLink.bindAsEventListener(a);
- linkDiv.appendChild(a);
- contentDiv.appendChild(linkDiv);
- empty = false;
- } else {
- contentDiv.innerHTML = t;
- empty = false;
- }
- }
- if (!empty) {
- this.domObj.style.visibility = 'hidden';
- this.domObj.style.display = 'block';
- var size = Element.getCoordinates(this.domObj);
- // 5 pixels offset added to clear the div from the mouse
- var mapOffsetX = this.getMap()._oDomObj.offsets[0];
- var mapOffsetY= this.getMap()._oDomObj.offsets[1];
-
- this.domObj.style.top = (this.oCurrentPosition.y ) + 'px';
- this.domObj.style.left = (this.oCurrentPosition.x )+ 'px';
-
- if (!window.opera) {
- contentDiv.appendChild(this.iframe);
- var size = Element.getContentBoxSize(this.domObj);
- this.iframe.style.width = size.width + "px";
- this.iframe.style.height = size.height + "px";
-
- }
-
- this.domObj.style.visibility = 'visible';
- //console.log("maptip visible");
-
- } else {
- this.hideMaptip();
- }
- } else {
- this.bIsVisible = false;
- this.hideMaptip();
- }
- },
-
- hideMaptip: function() {
- //console.log('hideMaptip');
- this.bIsVisible = false;
- this.hideTimer = window.setTimeout(this._hide.bind(this),10);
- },
-
- _hide: function() {
- //console.log('maptip _hide');
- this.hideTimer = null;
- this.domObj.style.display = 'none';
- //this.oMapTipPosition = null;
- },
-
- mouseOverTip: function() {
- //console.log('mouseOverTip');
- window.clearTimeout(this.nHideTimer);
- this.nHideTimer = null;
- this.bOverTip = true;
- },
-
- mouseOutTip: function() {
- //console.log('mouseOutTip');
- this.nHideTimer = window.setTimeout(this.hideMaptip.bind(this), 250);
- this.bOverTip = false;
- },
-
- openLink : function(evt) {
- var url = this.url;
- var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
- if ( taskPaneTarget ) {
- taskPaneTarget.setContent(url);
- } else {
- var pageElement = $(this.sTarget);
- if ( pageElement ) {
- pageElement.src = url;
- } else {
- window.open(url, this.sTarget, this.sWinFeatures);
- }
- }
- OpenLayers.Event.stop(evt, true);
- return false;
- }
- }
-);
Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Maptip.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -180,7 +180,7 @@
},
showMaptip: function() {
- this.getMap().getMapTip(this);
+ this.getMapLayer().getMapTip(this);
this.mapTipFired = true;
},
Modified: trunk/widgets/Measure.js
===================================================================
--- trunk/widgets/Measure.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Measure.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -493,13 +493,13 @@
remoteMeasureSegment: function(marker, from, to, geom) {
var mapWidget = this.getMap();
- var aMaps = mapWidget.getAllMaps();
- var s = 'layers/' + aMaps[0].arch + '/' + Fusion.getScriptLanguage() + "/Measure." + Fusion.getScriptLanguage();
+ var widgetLayer = this.getMapLayer();
+ var s = 'layers/' + widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/Measure." + Fusion.getScriptLanguage();
var fromGeo = mapWidget.pixToGeo(from.x, from.y);
var toGeo = mapWidget.pixToGeo(to.x, to.y);
var options = {
parameters: {
- 'session': aMaps[0].getSessionID(),
+ 'session': widgetLayer.getSessionID(),
'locale': Fusion.locale,
'mapname': mapWidget.getMapName(),
'x1': fromGeo.x,
Modified: trunk/widgets/Print.js
===================================================================
--- trunk/widgets/Print.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Print.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -168,9 +168,9 @@
var centerY = (extents.top + extents.bottom)/ 2;
var dpi = mainMap._nDpi;
var scale = mainMap.getScale();
- var maps = mainMap.getAllMaps();
- url = url + 'MAPNAME=' + mainMap.getMapName();
- url = url + '&SESSION=' + maps[0].getSessionID();
+ var widgetLayer = this.getMapLayer();
+ url = url + 'MAPNAME=' + widgetLayer.getMapName();
+ url = url + '&SESSION=' + widgetLayer.getSessionID();
url = url + '&CENTERX='+centerX;
url = url + '&CENTERY='+centerY;
url = url + '&DPI='+dpi;
Modified: trunk/widgets/Query.js
===================================================================
--- trunk/widgets/Query.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Query.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -51,15 +51,14 @@
var url = this.sBaseUrl;
//add in other parameters to the url here
- var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('LOCALE='+Fusion.locale);
- params.push('SESSION='+mapLayers[0].getSessionID());
- params.push('MAPNAME='+mapLayers[0].getMapName());
+ params.push('SESSION='+widgetLayer.getSessionID());
+ params.push('MAPNAME='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('POPUP=false');
} else {
Modified: trunk/widgets/QuickPlot.js
===================================================================
--- trunk/widgets/QuickPlot.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/QuickPlot.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -44,15 +44,14 @@
activate: function()
{
var url = this.sBaseUrl;
- var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('locale='+Fusion.locale);
- params.push('session='+mapLayers[0].getSessionID());
- params.push('mapname='+mapLayers[0].getMapName());
+ params.push('session='+widgetLayer.getSessionID());
+ params.push('mapname='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement)
{
@@ -113,7 +112,7 @@
***************************************************************************************/
preview: function(dialogConentLoadedCallback, printDpi)
{
- var map = this.getMap();
+ var map = this.getMapLayer();
var capture = this.mapCapturer.getCaptureBox();
var normalizedCapture = this.mapCapturer.getNormalizedCapture();
var vertices = capture.geometry.getVertices();
Modified: trunk/widgets/SaveMap.js
===================================================================
--- trunk/widgets/SaveMap.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SaveMap.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -197,7 +197,7 @@
if (this.imageWidth) {
szWidth = '&width=' + this.imageWidth;
}
- var m = this.getMap().aMaps[0];
+ var m = this.getMapLayer();
if(navigator.appVersion.match(/\bMSIE\b/)) {
var url = Fusion.fusionURL + 'layers/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMapFrame." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format.toUpperCase() + szLayout + szScale + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
w = open(url, "Save", 'menubar=no,height=200,width=300');
Modified: trunk/widgets/Search.js
===================================================================
--- trunk/widgets/Search.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Search.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -53,15 +53,14 @@
var url = this.sBaseUrl;
//add in other parameters to the url here
- var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('locale='+Fusion.locale);
- params.push('session='+mapLayers[0].getSessionID());
- params.push('mapname='+mapLayers[0].getMapName());
+ params.push('session='+widgetLayer.getSessionID());
+ params.push('mapname='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('popup=false');
} else {
Modified: trunk/widgets/SelectAttribute.js
===================================================================
--- trunk/widgets/SelectAttribute.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SelectAttribute.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -68,7 +68,7 @@
listLayers: function() {
//this.layerList.empty();
this.layerList.innerHTML = '';
- var map = this.getMap().aMaps[0];
+ var map = this.getMapLayer();
this.layerList.options[this.layerList.options.length] = new Option('--select--','');
for (var i=0; i<map.aLayers.length; ++i) {
var layer = map.aLayers[i];
@@ -116,10 +116,10 @@
activateLayer: function(event) {
if (this.drawn) {
var layer = this.layerList[this.layerList.selectedIndex].value;
- var map = this.getMap();
- for (var i=0; i<map.aMaps[0].aLayers.length; ++i) {
- if (map.aMaps[0].aLayers[i].layerName == layer) {
- map.setActiveLayer(map.aMaps[0].aLayers[i]);
+ var map = this.getMapLayer();
+ for (var i=0; i<map.aLayers.length; ++i) {
+ if (map.aLayers[i].layerName == layer) {
+ map.setActiveLayer(map.aLayers[i]);
break;
}
}
Modified: trunk/widgets/SelectRadius.js
===================================================================
--- trunk/widgets/SelectRadius.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SelectRadius.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -114,10 +114,11 @@
var radius = this.getMap().pixToGeoMeasure(this.defaultRadius);
this.handler.setOptions({radius: radius});
this.handler.activate();
- this.getMap().setCursor(this.asCursor);
+ var map = this.getMap();
+ map.setCursor(this.asCursor);
/*map units for tool tip*/
- this.units = this.getMap().getAllMaps()[0].units;
- this.getMap().supressContextMenu(true);
+ this.units = map.units;
+ map.supressContextMenu(true);
this.triggerEvent(Fusion.Event.RADIUS_WIDGET_ACTIVATED, true);
},
Modified: trunk/widgets/SelectRadiusValue.js
===================================================================
--- trunk/widgets/SelectRadiusValue.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SelectRadiusValue.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -50,7 +50,7 @@
draw: function() {
/* put in the label */
- var units = this.getMap().getAllMaps()[0].units;
+ var units = this.getMap().units;
this.domLabel = document.createElement('span');
this.domLabel.className = this.className;
this.domLabel.innerHTML = this.label + '(' + units + ')';
Modified: trunk/widgets/SelectWithin.js
===================================================================
--- trunk/widgets/SelectWithin.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SelectWithin.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -89,15 +89,14 @@
var url = this.sBaseUrl;
//add in other parameters to the url here
- var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('locale='+Fusion.locale);
- params.push('session='+mapLayers[0].getSessionID());
- params.push('mapname='+mapLayers[0].getMapName());
+ params.push('session='+widgetLayer.getSessionID());
+ params.push('mapname='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('popup=false');
} else {
Modified: trunk/widgets/SelectionPanel.js
===================================================================
--- trunk/widgets/SelectionPanel.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/SelectionPanel.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -503,7 +503,7 @@
var layerObj = this.oSelection.getLayer(i);
var aNames = layerObj.getPropertyNames();
//find the legend label from the Map layer objects
- var mapLayers = this.getMap().aMaps[0].aLayers; //TODO: allow multiple maps
+ var mapLayers = this.getMapLayer().aLayers;
var labelName = layerObj.getName();
for (var j=0; j<mapLayers.length; ++j) {
if (mapLayers[j].layerName == labelName) {
Modified: trunk/widgets/TaskPane.js
===================================================================
--- trunk/widgets/TaskPane.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/TaskPane.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -171,15 +171,15 @@
//add in some common parameters if they aren't supplied already
var baseUrl = url.split("?");
var params = OpenLayers.Util.getParameters(url);
- var mapLayers = this.getMap().getAllMaps();
+ var widgetLayer = this.getMapLayer();
if (!params["LOCALE"] && !params["locale"]) {
params["locale"] = Fusion.locale;
}
if (!params["SESSION"] && !params["session"]) {
- params["session"] = mapLayers[0].getSessionID();
+ params["session"] = widgetLayer.getSessionID();
}
if (!params["MAPNAME"] && !params["mapname"]) {
- params["mapname"] = mapLayers[0].getMapName();
+ params["mapname"] = widgetLayer.getMapName();
}
var newUrl = baseUrl[0] + "?" + OpenLayers.Util.getParameterString(params);
Modified: trunk/widgets/Theme.js
===================================================================
--- trunk/widgets/Theme.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/Theme.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -50,15 +50,14 @@
var url = this.sBaseUrl;
//add in other parameters to the url here
- var map = this.getMap();
- var mapLayers = map.getAllMaps();
+ var widgetLayer = this.getMapLayer();
var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
var pageElement = $(this.sTarget);
var params = [];
params.push('LOCALE='+Fusion.locale);
- params.push('SESSION='+mapLayers[0].getSessionID());
- params.push('MAPNAME='+mapLayers[0].getMapName());
+ params.push('SESSION='+widgetLayer.getSessionID());
+ params.push('MAPNAME='+widgetLayer.getMapName());
if (taskPaneTarget || pageElement) {
params.push('POPUP=false');
} else {
Modified: trunk/widgets/ZoomToSelection.js
===================================================================
--- trunk/widgets/ZoomToSelection.js 2011-01-06 16:05:51 UTC (rev 2312)
+++ trunk/widgets/ZoomToSelection.js 2011-01-07 20:36:04 UTC (rev 2313)
@@ -59,18 +59,25 @@
*
* @param selection the active selection, or null if there is none
*/
- zoomToSelection : function(selection) {
- var map = this.oMap.aMaps[0]; //TODO: allow selection on multple maps
- var ll = selection[map.getMapName()].getLowerLeftCoord();
- var ur = selection[map.getMapName()].getUpperRightCoord();
- var zoom_size = this.zoomFactor * Math.max( Math.abs(ur.x - ll.x), Math.abs(ur.y - ll.y)) / 2;
- var cX = (ur.x + ll.x)/2;
- var cY = (ur.y + ll.y)/2;
- ll.x = cX - zoom_size;
- ur.x = cX + zoom_size;
- ll.y = cY - zoom_size;
- ur.y = cY + zoom_size;
- this.getMap().setExtents(new OpenLayers.Bounds(ll.x,ll.y,ur.x,ur.y));
+ zoomToSelection: function(selection) {
+ var aMaps = this.getMap().getAllMaps();
+ var bounds = new OpenLayers.Bounds();
+ for (var i=0; i<aMaps.length; ++i) {
+ var mapName = aMaps[i].getMapName()
+ if (selection[mapName]) {
+ var ll = selection[mapName].getLowerLeftCoord();//make this an OL Pixel
+ bounds.extend(new OpenLayers.LonLat(ll.x,ll.y));
+ var ur = selection[mapName].getUpperRightCoord();
+ bounds.extend(new OpenLayers.LonLat(ur.x,ur.y));
+ }
+ }
+ var zoom_size = this.zoomFactor * Math.max( Math.abs(bounds.getWidth()), Math.abs(bounds.getHeight())) / 2;
+ var center = bounds.getCenterLonLat();
+ llx = center.lon - zoom_size;
+ urx = center.lon + zoom_size;
+ lly = center.lat - zoom_size;
+ ury = center.lat + zoom_size;
+ this.getMap().setExtents(new OpenLayers.Bounds(llx,lly,urx,ury));
},
enable: function() {
More information about the fusion-commits
mailing list