[fusion-commits] r1771 - in trunk: layers/MapGuide layers/MapServer
lib widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Feb 3 15:55:51 EST 2009
Author: madair
Date: 2009-02-03 15:55:51 -0500 (Tue, 03 Feb 2009)
New Revision: 1771
Modified:
trunk/layers/MapGuide/MapGuide.js
trunk/layers/MapServer/MapServer.js
trunk/lib/Map.js
trunk/widgets/Maptip.js
Log:
re #127: refactor maptip code into the MapGuide layer type (as was done for MapServer) - also related to issue #166
Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js 2009-02-03 20:13:48 UTC (rev 1770)
+++ trunk/layers/MapGuide/MapGuide.js 2009-02-03 20:55:51 UTC (rev 1771)
@@ -1095,7 +1095,54 @@
return queryParams;
},
+
+ getMapTip: function(mapTipWidget) {
+ //console.log('showMaptip');
+ var oBroker = Fusion.oBroker;
+ var x = mapTipWidget.oCurrentPosition.x;
+ var y = mapTipWidget.oCurrentPosition.y;
+ var min = this.mapWidget.pixToGeo(x-mapTipWidget.nTolerance, y-mapTipWidget.nTolerance);
+ var max = this.mapWidget.pixToGeo(x+mapTipWidget.nTolerance, y+mapTipWidget.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 sGeometry = 'POINT('+ 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;
+ //TODO: possibly make the layer names configurable?
+ var layerNames = mapTipWidget.aLayers.toString();
+ var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(this.getSessionID(),
+ this._sMapname,
+ sGeometry,
+ maxFeatures, persist, selection, layerNames,
+ layerAttributeFilter);
+ oBroker.dispatchRequest(r,
+ OpenLayers.Function.bind(Fusion.xml2json, this,
+ OpenLayers.Function.bind(this.parseMapTip, this)));
+ },
+
+ parseMapTip: function(xhr) {
+ var o;
+ eval("tooltip="+xhr.responseText);
+ this.oMaptip = {t:"",h:""};
+ var t = tooltip['FeatureInformation']['Tooltip'];
+ if (t) {
+ this.oMaptip.t = t[0].replace(/\\n/g, "<br>");
+ }
+ var h = tooltip['FeatureInformation']['Hyperlink'];
+ if (h) {
+ this.oMaptip.h = h[0];
+ }
+ this.mapWidget.triggerEvent(Fusion.Event.MAP_MAPTIP_REQ_FINISHED, this.oMaptip);
+ },
+
getLegendImageURL: function(fScale, layer, style) {
var url = Fusion.getConfigurationItem('mapguide', 'mapAgentUrl');
url += "?OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID();
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2009-02-03 20:13:48 UTC (rev 1770)
+++ trunk/layers/MapServer/MapServer.js 2009-02-03 20:55:51 UTC (rev 1771)
@@ -29,7 +29,6 @@
* Implementation of the map widget for MapServer CGI interface services
*/
Fusion.Event.MAP_LAYER_ORDER_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Event.MAP_MAPTIP_REQ_FINISHED = Fusion.Event.lastEventId++;
Fusion.Layers.MapServer = OpenLayers.Class(Fusion.Layers, {
arch: 'MapServer',
@@ -50,7 +49,6 @@
//console.log('Fusion.Layers.MapServer.initialize');
Fusion.Layers.prototype.initialize.apply(this, arguments);
this.registerEventID(Fusion.Event.MAP_SESSION_CREATED);
- this.registerEventID(Fusion.Event.MAP_MAPTIP_REQ_FINISHED);
//this.selectionType = extension.SelectionType ? extension.SelectionType[0] : 'INTERSECTS';
this.sMapFile = mapTag.extension.MapFile ? mapTag.extension.MapFile[0] : '';
@@ -768,13 +766,13 @@
return oLayer;
},
- getMetadata: function(key) {
- if (typeof this.metadata[key] != 'undefined') {
- return this.metadata[key];
- } else {
- return '';
- }
- },
+ getMetadata: function(key) {
+ if (typeof this.metadata[key] != 'undefined') {
+ return this.metadata[key];
+ } else {
+ return '';
+ }
+ },
getLegendImageURL: function(fScale, layer) {
var sl = Fusion.getScriptLanguage();
@@ -784,31 +782,27 @@
return url + '?'+params;
},
- getMapTip: function(oMapTips,oOptions){
+ getMapTip: function(oMapTips){
//console.log("MAPSERVER:getMapTip");
var pos = this.mapWidget.pixToGeo(oMapTips.oCurrentPosition.x, oMapTips.oCurrentPosition.y);
- var options = {};
- var dfGeoTolerance = this.mapWidget.pixToGeoMeasure(oOptions.nTolerance);
+ var dfGeoTolerance = this.mapWidget.pixToGeoMeasure(oMapTips.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";
+ var geometry = 'POLYGON(('+ minx + ' ' + miny + ', ' + minx + ' ' + maxy + ', ' + maxx + ' ' + maxy + ', ' + maxx + ' ' + miny + ', ' + minx + ' ' + miny + '))';
+ var selectionType = "INTERSECTS";
- var Map = this.mapWidget.aMaps[0];
- var bPersistant = options.persistent || true;
- var zoomTo = options.zoomTo ? true : false;
- var loadmapScript = '/layers/'+Map.arch + '/php/Maptip.php';
+ var loadmapScript = '/layers/'+ this.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': oOptions.layer[0] || '',
- 'textfield': oOptions.textField || '',
- 'customURL': oOptions.customURL || ''
+ 'mapname': this._sMapname,
+ 'session': this.getSessionID(),
+ 'spatialfilter': geometry,
+ 'maxfeatures': 0, //zero means select all features
+ 'variant': selectionType,
+ 'layer': oMapTips.aLayers[0] || '',
+ 'textfield': oMapTips.textField || '',
+ 'customURL': oMapTips.customURL || ''
}
var parseMapTip = this.parseMapTip.bind(this);
var ajaxOptions = {
@@ -822,10 +816,10 @@
parseMapTip: function(json){
this.oMaptip = {};
- this.oMaptip.t =json.mapTipText;
- this.oMaptip. h =json.mapTipLink;
- this.triggerEvent(Fusion.Event.MAP_MAPTIP_REQ_FINISHED,this.oMaptip);
- },
+ this.oMaptip.t = json.mapTipText;
+ this.oMaptip.h = json.mapTipLink;
+ this.mapWidget.triggerEvent(Fusion.Event.MAP_MAPTIP_REQ_FINISHED, this.oMaptip);
+ }
});
Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js 2009-02-03 20:13:48 UTC (rev 1770)
+++ trunk/lib/Map.js 2009-02-03 20:55:51 UTC (rev 1771)
@@ -40,6 +40,7 @@
Fusion.Event.MAP_LOADING = Fusion.Event.lastEventId++;
Fusion.Event.MAP_RELOADED = Fusion.Event.lastEventId++;
Fusion.Event.MAP_SESSION_CREATED = Fusion.Event.lastEventId++;
+Fusion.Event.MAP_MAPTIP_REQ_FINISHED = Fusion.Event.lastEventId++;
Fusion.Constant.LAYER_POINT_TYPE = 0;
@@ -166,6 +167,7 @@
this.registerEventID(Fusion.Event.MAP_RELOADED);
this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
+ this.registerEventID(Fusion.Event.MAP_MAPTIP_REQ_FINISHED);
this.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded,this));
@@ -1009,6 +1011,11 @@
return OpenLayers.Util.getParameterString(queryParams);
},
+ getMapTip: function(oMapTips) {
+ //TODO send this to the correct aMap object
+ this.aMaps[0].getMapTip(oMapTips);
+ },
+
supressContextMenu: function( bSupress ) {
this.bSupressContextMenu = bSupress;
},
Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js 2009-02-03 20:13:48 UTC (rev 1770)
+++ trunk/widgets/Maptip.js 2009-02-03 20:55:51 UTC (rev 1771)
@@ -70,9 +70,14 @@
this.delay = json.Delay ? parseInt(json.Delay[0]) : 350;
this.nTolerance = json.Tolerance ? parseInt(json.Tolerance[0]) : 2;
- this.layer = json.Layer;
this.customURL = json.CustomURL;
this.textField = json.TextField;
+ this.aLayers = [];
+ if (json.Layer) {
+ for (var i=0; i<json.Layer.length; i++) {
+ this.aLayers.push(json.Layer[i]);
+ }
+ }
//prepare the container div for the maptips
Fusion.addWidgetStyleSheet(widgetTag.location + 'Maptip/Maptip.css');
@@ -104,7 +109,7 @@
this.getMap().observeEvent('mouseout', OpenLayers.Function.bind(this.mouseOut, this));
this.eventListener = false;
- this.getMap().aMaps[0].registerForEvent(Fusion.Event.MAP_MAPTIP_REQ_FINISHED,OpenLayers.Function.bind(this._display,this));
+ this.getMap().registerForEvent(Fusion.Event.MAP_MAPTIP_REQ_FINISHED,OpenLayers.Function.bind(this._display,this));
},
@@ -142,14 +147,7 @@
this.nTimer = null;
}
- this.options = {};
- this.options.e = e;
- this.options.nTolerance = this.nTolerance;
- this.options.textField = this.textField
- this.options.layer = this.layer
- this.options.customURL = this.customURL
-
- this.nTimer = window.setTimeout(OpenLayers.Function.bind(this.showMaptip, this,this.options,e), this.delay);
+ this.nTimer = window.setTimeout(OpenLayers.Function.bind(this.showMaptip, this), this.delay);
//Event.stop(e);
},
@@ -162,9 +160,9 @@
this.mouseIsDown = false;
},
- showMaptip: function(oOptions) {
+ showMaptip: function() {
//console.log("MAPTIP: showMaptip");
- this.getMap().aMaps[0].getMapTip(this,oOptions);
+ this.getMap().getMapTip(this);
},
More information about the fusion-commits
mailing list