[mapguide-users] GetMapImage
wordsy
mwordell at gmail.com
Mon Dec 29 18:33:12 EST 2008
I am hoping someone here has had the same problem.
My scenario:
I have a grid of items that are on a map (layers etc). This page does not
have the main map. I have a requirement where a user can click on the item
in the grid (asp.net datagrid) and they will be able to see a preview of the
item they have clicked on. I am using the GetMapImage in a user control. I
have successfully created the control so it goes to the item picked in the
list and renders that image. The only problem I have is actually selecting
the item in the map by.
Here is the code I am using:
string searchstring = "SpatialKey = '" + this.RadTextBox1.Text + "'";
MgFeatureQueryOptions DisplayIdQuery = new
MgFeatureQueryOptions();
DisplayIdQuery.SetFilter(searchstring);
MgUserInformation userInfo = new
MgUserInformation(Session[SessionStateBase.SESSION_GIS_SESSION_ID].ToString());
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
// get the map
MgMap map = new MgMap(siteConnection);
map.Open(Session[SessionStateBase.SESSION_MUNICIPALITY].ToString());
MgAgfReaderWriter geometryReaderWriter = new
MgAgfReaderWriter();
MgLayer layer = map.GetLayers().GetItem(LayerName) as MgLayer;
MgFeatureReader featureReader =
layer.SelectFeatures(DisplayIdQuery);
featureReader.ReadNext();
MgByteReader byteReader = featureReader.GetGeometry("Geometry");
MgGeometry geometry = geometryReaderWriter.Read(byteReader);
MgPoint point = geometry.GetCentroid();
double x = point.GetCoordinate().GetX();
double y = point.GetCoordinate().GetY();
MgSelection selection = new MgSelection(map);
/////THIS IS WHERE I AM HAVING THE PROBLEM/////
selection.AddFeatures(layer, featureReader, 0);
//selection.Add(layer.GetObjectId(), map.GetClassName(),
this.RadTextBox1.Text);
String selectionXml = selection.ToXml();
selectionXml = Regex.Replace(Server.UrlEncode(selectionXml),
"%.{2}", new MatchEvaluator(CapitalizeEncoding));
this.Image1.ImageUrl =
"http://vmedmgis/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&VERSION=1.0.0&SESSION="
+ Session[SessionStateBase.SESSION_GIS_SESSION_ID] + "&MAPNAME=" +
Session[SessionStateBase.SESSION_MUNICIPALITY] +
"&LOCALE=en&MAPDEFINITION=Library%3A%2F%2F&FORMAT=PNG&SELECTION=" +
selectionXml + "&SETVIEWCENTERX=" + x.ToString() + "&SETVIEWCENTERY=" +
y.ToString() + "&SETVIEWSCALE=" + ViewScale.ToString() +
"&SETDISPLAYDPI=75&SETDISPLAYWIDTH=375&SETDISPLAYHEIGHT=250&SHOWLAYERS=&HIDELAYERS=&SHOWGROUPS=&HIDEGROUPS=&CLIP=0";
When I select the item on the map and get the selectionXml javascript
function I get
<?xml version="1.0" encoding="UTF-8"?>
<FeatureSet>
<Layer id="6b85dffc-0000-1000-8000-005056c00008">
<Class id="Classname">
<ID>3QEAAA==</ID>
</Class>
</Layer>
</FeatureSet>
but when I run String selectionXml = selection.ToXml();
my code doesn't resemble the javascript xml. Below is what I get.
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<FeatureSet xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:noNamespaceSchemaLocation=\"FeatureSet-1.0.0.xsd\">
</FeatureSet>
As you can see, there is a major difference between the 2 selection xml.
When I pass the selection xml generated by the server side code to the
GetMapImage function the formats aren't the same.
Any ideas why? Thanks for any help in advance.
--
View this message in context: http://n2.nabble.com/GetMapImage-tp2090701p2090701.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list