[mapguide-commits] r7474 - sandbox/jng/queryfeatures_v2/Web/src/viewerfiles
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri May 3 15:41:30 PDT 2013
Author: jng
Date: 2013-05-03 15:41:29 -0700 (Fri, 03 May 2013)
New Revision: 7474
Modified:
sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ
Log:
AJAX Viewer updates:
- Number crunch the selection bounding box client-side
- Use the crunched bounding box for ZoomSelection(). This eliminates *yet another* request to the mapagent (GETFEATURESETENVELOPE)
Modified: sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ
===================================================================
--- sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ 2013-05-03 22:23:24 UTC (rev 7473)
+++ sandbox/jng/queryfeatures_v2/Web/src/viewerfiles/ajaxmappane.templ 2013-05-03 22:41:29 UTC (rev 7474)
@@ -3241,13 +3241,15 @@
SetSelection("", false);
+ selFeatures = {};
+ selBounds = null;
+
selImg = document.getElementById(msie6minus ? "selImg1div": curSelImg);
if(selImg)
{
selImg.style.visibility = "hidden";
}
-
parent.OnSelectionChanged();
}
@@ -3264,32 +3266,15 @@
function ZoomSelection()
{
- if(selection.count == 0)
+ if(selection.count == 0 || !selBounds)
return;
-
- var reqParams = "OPERATION=GETFEATURESETENVELOPE&VERSION=1.0.0&SESSION=" + sessionId + "&MAPNAME=" + encodeURIComponent(mapName) + "&SEQ=" + Math.random();
- reqParams += "&FEATURESET=" + encodeURIComponent(selectionToXml()) + "&CLIENTAGENT=" + encodeURIComponent(clientAgent);
-
- dr = CreateRequestHandler();
- dr.open("POST", webAgent, false);
- dr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- dr.send(reqParams);
-
- if(dr.status == 200)
- {
- var env = ParseEnvelope(dr.responseXML.documentElement);
- if(env != null)
- {
- var mcsW = env.upperRight.X - env.lowerLeft.X;
- var mcsH = env.upperRight.Y - env.lowerLeft.Y;
- var centerX = env.lowerLeft.X + mcsW / 2;
- var centerY = env.lowerLeft.Y + mcsH / 2;
- var scale = CalculateScale1(mcsW*2, mcsH*2, mapDevW, mapDevH);
- GotoView(centerX, centerY, scale, true, true);
- }
- }
- else
- RequestFailed(dr.responseText);
+
+ var mcsW = selBounds.maxx - selBounds.minx;
+ var mcsH = selBounds.maxy - selBounds.miny;
+ var centerX = selBounds.minx + mcsW / 2;
+ var centerY = selBounds.miny + mcsH / 2;
+ var scale = CalculateScale1(mcsW*2, mcsH*2, mapDevW, mapDevH);
+ GotoView(centerX, centerY, scale, true, true);
}
function ParseEnvelope(xmlRoot)
@@ -4194,7 +4179,7 @@
else if (name == "_MgFeatureBoundingBox")
{
var values = value.split(" ");
- feat.zoom = { minx: values[0], miny: values[1], maxx: values[2], maxy: values[3] };
+ feat.zoom = { minx: parseFloat(values[0]), miny: parseFloat(values[1]), maxx: parseFloat(values[2]), maxy: parseFloat(values[3]) };
}
else
{
@@ -4235,7 +4220,7 @@
selBounds = null;
if (!resp)
return;
-
+
var selLayers = document.getElementById("selLayers");
selLayers.length = 0;
GetPropertyCtrl().Clear();
@@ -4254,6 +4239,26 @@
//Associates the selected features on layer
selFeatures[layerName] = resp[layerName];
+
+ //Update selection bounding box
+ for (var i = 0; i < resp[layerName].length; i++)
+ {
+ var feat = resp[layerName][i];
+ if (feat.zoom) {
+ if (!selBounds) {
+ selBounds = { minx: feat.zoom.minx, miny: feat.zoom.miny, maxx: feat.zoom.maxx, maxy: feat.zoom.maxy };
+ } else {
+ if (feat.zoom.minx < selBounds.minx)
+ selBounds.minx = feat.zoom.minx;
+ if (feat.zoom.miny < selBounds.miny)
+ selBounds.miny = feat.zoom.miny;
+ if (feat.zoom.maxx > selBounds.maxx)
+ selBounds.maxx = feat.zoom.maxx;
+ if (feat.zoom.maxy > selBounds.maxy)
+ selBounds.maxy = feat.zoom.maxy;
+ }
+ }
+ }
}
if (selLayers.length > 0)
More information about the mapguide-commits
mailing list