[mapguide-users] how to get selected feature
andrea tiveron (e-metodi)
andrea.tiveron at e-metodi.it
Tue Feb 2 09:22:53 EST 2010
this is an example that I find
I hope that this help you
andrea
<%@ Page Language="C#" ValidateRequest="false" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<script runat="server">
public String OutputSelectionInHTML(MgSelection selection,
MgFeatureService featureService)
{
MgReadOnlyLayerCollection layers = selection.GetLayers();
String outString = null;
MgFeatureReader featReader = null;
if (layers != null)
{
for (int i = 0; i < layers.GetCount(); i++)
{
MgLayer layer = (MgLayer)layers.GetItem(i);
if ((layer != null) && (layer.GetName() == "Parcels"))
{
String layerClassName = layer.GetFeatureClassName();
String selectString = selection.GenerateFilter(layer,
layerClassName);
String layerFeatureIdString =
layer.GetFeatureSourceId();
MgResourceIdentifier layerResId = new
MgResourceIdentifier(layerFeatureIdString);
MgFeatureQueryOptions queryOptions = new
MgFeatureQueryOptions();
queryOptions.SetFilter(selectString);
featReader = featureService.SelectFeatures(layerResId,
layerClassName, queryOptions);
outString = outString + "<table border=\"1\">\n";
double acre = 0;
while (featReader.ReadNext())
{
outString = outString + "<tr>\n";
outString = outString + "<td>";
outString = outString +
featReader.GetString("RNAME");
outString = outString + "</td>\n";
outString = outString + "<td>";
outString = outString +
featReader.GetString("RPROPAD");
outString = outString + "</td>\n";
outString = outString + "<td>";
String acreString = featReader.GetString("RACRE");
acre = acre + (acreString == "" ? 0 :
Convert.ToDouble(acreString));
outString = outString + acreString;
outString = outString + "</tr>\n";
}
outString = outString + "</table>\n";
}
}
}
return outString;
}
</script>
<%
String sessionID = Request.Form.Get("SESSION");
string realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
String configPath = realPath + "webconfig.ini";
MapGuideApi.MgInitializeWebTier(configPath);
MgUserInformation userInfo = new MgUserInformation(sessionID);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
String selString = Request.Form.Get("SELECTION");
String selection = HttpUtility.UrlDecode(selString);
MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceServic
e);
MgFeatureService featService =
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService)
;
MgMap map = new MgMap();
map.Open(resService, "Sheboygan");
MgSelection mapSelection = new MgSelection(map, selection);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>List Selection</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<link href="styles/globalstyles.css" rel="stylesheet" type="text/css" />
<link href="styles/alphastyles.css" rel="stylesheet" type="text/css" />
</head>
<body class="AppFrame">
<%
if (mapSelection.GetLayers() != null)
{
Response.Write("<div class=\"bold\" style=\"font-size:
15pt;\">\n");
Response.Write("The following parcels are selected on the
map.\n");
Response.Write("</div><br>\n");
Response.Write(OutputSelectionInHTML(mapSelection,
featService));
}
else
{
%>
<div class="bold" style="font-size: 15pt;">
Please first make a selection on the map with a selection tool.
</div>
<%
}
%>
</body>
</html>
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of prabhat30
Sent: lunedì 1 febbraio 2010 14.42
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] how to get selected feature
Hi ,
I am trying to get all the fields data of a selected feature ( any feature
). send me some sample codes to do so.... thanks in advance....
--
View this message in context:
http://n2.nabble.com/how-to-get-selected-feature-tp4494406p4494406.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
--
This message was scanned by ESVA and is believed to be clean.
More information about the mapguide-users
mailing list