[mapguide-commits] r7471 - sandbox/jng/queryfeatures_v2/Web/src/viewerfiles
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri May 3 13:39:11 PDT 2013
Author: jng
Date: 2013-05-03 13:39:11 -0700 (Fri, 03 May 2013)
New Revision: 7471
Modified:
sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ
sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/browserdetect.js
Log:
Here's the AJAX viewer side of the equation:
- Update browserdetect.js to include msie8. This was the first version of ie to support data URIs
- Update QueryFeatureInfo() as follows:
- Abort if we get illegal geometry wkt
- Send off a v2.6.0 QUERYMAPFEATURES request with attributes by default. If data URIs are supported, request an inline selection as well.
- Update ProcessFeatureInfo() as follows:
- If selection attributes were requested, convert the new v2.6.0 XML response into a form required for our property pane, and go straight to the property pane update.
- Add a new GetSelectedFeatures() API to retrieve the processed selection set.
- Extract out the img generation code in RequestSelectionImage() to a separate PutSelectionImageUrl() method, allowing us to put the inline selection data uri directly when we finally get that thing to work server-side.
Modified: sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ
===================================================================
--- sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ 2013-05-03 20:30:42 UTC (rev 7470)
+++ sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ 2013-05-03 20:39:11 UTC (rev 7471)
@@ -532,6 +532,16 @@
return digitizing;
}
+function GetSelectedFeatures()
+{
+ return selFeatures;
+}
+
+function GetSelectedFeatureBounds()
+{
+ return selBounds;
+}
+
// private functions -----------------------------------------------
//
function InitDocument()
@@ -1885,10 +1895,8 @@
document.getElementById("mapImage").src = document.getElementById("mapImage").src;
}
-function RequestSelectionImage(reqId, viewParams)
+function PutSelectionImageUrl(reqId, url)
{
- url = webAgent + "?OPERATION=GETDYNAMICMAPOVERLAYIMAGE&FORMAT=" + selectionImgFormat + "&VERSION=2.1.0&SESSION=" + sessionId + "&MAPNAME=" + encodeComponent(mapName) + "&SEQ=" + Math.random() + "&CLIENTAGENT=" + encodeComponent(clientAgent) + "&BEHAVIOR=5&SELECTIONCOLOR=" + selectionColor;
- url += viewParams;
if(safari || chrome)
{
LoadAlternateSelectionImage(url, reqId);
@@ -1902,6 +1910,13 @@
document.getElementById("selectionImage").src = document.getElementById("selectionImage").src;
}
+function RequestSelectionImage(reqId, viewParams)
+{
+ url = webAgent + "?OPERATION=GETDYNAMICMAPOVERLAYIMAGE&FORMAT=" + selectionImgFormat + "&VERSION=2.1.0&SESSION=" + sessionId + "&MAPNAME=" + encodeComponent(mapName) + "&SEQ=" + Math.random() + "&CLIENTAGENT=" + encodeComponent(clientAgent) + "&BEHAVIOR=5&SELECTIONCOLOR=" + selectionColor;
+ url += viewParams;
+ PutSelectionImageUrl(reqId, url);
+}
+
function OnMapOverlayImageLoaded(e)
{
ovimgloaded = true;
@@ -3018,8 +3033,14 @@
{
if(GetVisSelLayers() == "") return;
if(moveType != NONE) return;
- var reqParams = "OPERATION=QUERYMAPFEATURES&VERSION=1.0.0&PERSIST=1&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&SEQ=" + Math.random();
+ if(geom.indexOf("NaN") >= 0) return;
+
+ var reqData = 1; //attributes
+ if (!msie || msie8plus)
+ reqData |= 2; //inline selection
+ var reqParams = "OPERATION=QUERYMAPFEATURES&VERSION=2.6.0&PERSIST=1&MAPNAME=" + encodeURIComponent(mapName) + "&SESSION=" + sessionId + "&SEQ=" + Math.random();
reqParams += "&LAYERNAMES=" + encodeURIComponent(GetVisSelLayers()) + "&GEOMETRY=" + geom + "&SELECTIONVARIANT=" + queryVariant + "&CLIENTAGENT=" + encodeURIComponent(clientAgent);
+ reqParams += "&REQUESTDATA=" + reqData + "&SELECTIONCOLOR=" + selectionColor + "&SELECTIONFORMAT=" + selectionImgFormat;
if(maxfeatures != 0)
{
reqParams += "&MAXFEATURES=" + maxfeatures;
@@ -3138,7 +3159,14 @@
{
if (selection.count > 0)
{
- RequestSelectedFeatureProperties();
+ //Check if we have attributes inline
+ var props = xmlIn.getElementsByTagName("PropertyCollection");
+ if (props.length > 0) {
+ var resp = ConvertToSelectedFeatureSet(props);
+ ProcessSelectedFeatureSet(resp);
+ } else {
+ RequestSelectedFeatureProperties();
+ }
}
else
{
@@ -4131,7 +4159,41 @@
var hovered = "";
var active = "";
var selFeatures = {};
+var selBounds = null;
+function ConvertToSelectedFeatureSet(propCols)
+{
+ var featuresByLayer = {};
+ for (var i = 0; i < propCols.length; i++)
+ {
+ var feat = { values: [] };
+ var propColEl = propCols[i];
+ var propEls = propColEl.getElementsByTagName("Property");
+ for (var j = 0; j < propEls.length; j++)
+ {
+ //Name,Type,Value
+ var name = propEls[j].childNodes[0].textContent;
+ var value = propEls[j].childNodes[2].textContent;
+ if (name == "_MgLayerName")
+ {
+ if (!featuresByLayer[value])
+ featuresByLayer[value] = [];
+ featuresByLayer[value].push(feat);
+ }
+ else if (name == "_MgFeatureBoundingBox")
+ {
+ var values = value.split(" ");
+ feat.zoom = { minx: values[0], miny: values[1], maxx: values[2], maxy: values[3] };
+ }
+ else
+ {
+ feat.values.push({ name: name, value: value });
+ }
+ }
+ }
+ return featuresByLayer;
+}
+
function RequestSelectedFeatureProperties()
{
var mapname = GetMapName();
@@ -4159,6 +4221,7 @@
function ProcessSelectedFeatureSet(resp)
{
selFeatures = {};
+ selBounds = null;
if (!resp)
return;
Modified: sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/browserdetect.js
===================================================================
--- sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/browserdetect.js 2013-05-03 20:30:42 UTC (rev 7470)
+++ sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/browserdetect.js 2013-05-03 20:39:11 UTC (rev 7471)
@@ -27,6 +27,7 @@
var msieIndex = agent.indexOf("msie");
var msie = false;
var msie7plus = false;
+var msie8plus = false;
var msie6minus = false;
if(msieIndex != -1)
{
@@ -37,6 +38,11 @@
{
msie7plus = true;
}
+ else if (parseFloat(msieVersion) >= 8)
+ {
+ msie7plus = true;
+ msie8plus = true;
+ }
else
{
msie6minus = true;
More information about the mapguide-commits
mailing list