Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mapguide Kaliopa Mobile Viewer Display Report

1 REPLY 1
SOLVED
Reply
Message 1 of 2
reno.sun.gis
714 Views, 1 Reply

Mapguide Kaliopa Mobile Viewer Display Report

Hello Guys,
Dose anyone use Mapguide Kaliopa Mobile Viewer as their mobile viewer for their AIMS/Mapguide map server?


The viewer is working quite well on mobile device compared to AIMS original mobile viewer.


The MultiGrid Show.aspx which is used to display the properties (Attributes & Values) of selected features on the map does not recognize the layer attribute visible setting in Autodesk Infrastructure Studio.

 

AIS_Capture.JPG


It displays all the attributes of the selected features no matter you checked or not checked to display the attributes in Infrastructure Studio.


Dose anyone know how/what should I modify the code to display only the attributes that I would like to show the users? Is there a 

 

"reader.GetProperty.Visible == True" likely code that I can use for filter out the attributes that I don't want to display?

 

Thank you very much.

 

Response.Cache.SetCacheability(HttpCacheability.NoCache);

string sessionId = Request["sessionId"];
string mapName = Request["mapName"];
string selection = Request["selection"];

if (string.IsNullOrEmpty(sessionId)) return; //required parameter
if (string.IsNullOrEmpty(mapName)) return; //required parameter

string zoomTempl = ""; //template for button zoom ...
string selectTempl = ""; //template for button select ...

Response.Write("<table class=\"table table-responsive table-bordered table-striped\">");

//Response.Write("<tr class=\"noprint\"><td><hr /></td></tr>");

if (string.IsNullOrEmpty(selection))
{
//other ways to get selection ...
}
else
{
selection = Server.HtmlDecode(selection);
}

if (!string.IsNullOrEmpty(selection))
{
MgResourceService resourceSrvc = GetMgResurceService(sessionId);
MgFeatureService featureService = GetMgFeatureService(sessionId);

MgMap map = new MgMap();
map.Open(resourceSrvc, mapName);

MgSelection sel = new MgSelection(map, selection);

foreach (MgLayerBase layer in sel.GetLayers())
{
Response.Write("<tr><td><b>" + layer.LegendLabel + "</b></td></tr>");
Response.Write(
"<tr><td><table class=\"table table-responsive table-bordered table-striped\" align=\"left\" CELLPADDING=\"2\" CELLSPACING=\"2\">");

try
{
string filter = sel.GenerateFilter(layer, layer.GetFeatureClassName());
MgResourceIdentifier resId = new MgResourceIdentifier(layer.GetFeatureSourceId());
MgFeatureQueryOptions query = new MgFeatureQueryOptions();
query.SetFilter(filter);
MgDataPropertyDefinition idProperty = GetIdProperty(featureService, layer);

List<string> featIds = new List<string>();
MgFeatureReader reader = featureService.SelectFeatures(resId, layer.GetFeatureClassName(), query);
string geom = layer.GetFeatureGeometryName().ToLower();

Response.Write("<tr><th class=\"header\"></th><th class=\"header\"></th><th class=\"header\"></th>");
for (int i = 0; i < reader.GetPropertyCount(); i++)
{
if (reader.GetPropertyName(i).ToLower() != geom)
{
Response.Write("<th valign=\"middle\" class=\"header\">" + reader.GetPropertyName(i) +
"</th>");
}
}
Response.Write("</tr>");
Response.Flush();

int autonumber = 1;

while (reader.ReadNext())
{
string clas = "main";
if (autonumber % 2 == 0) clas = "main2";

Response.Write("<tr onmouseover=\"LineOn(event)\" onmouseout=\"LineOff(event)\">");
Response.Write("<td align=center class=" + clas + "><b>" + autonumber.ToString() +
"</b></td>");

Response.Write("<td align=center class=" + clas + "><b>" + string.Format(zoomTempl, layer.Name, GetPropertyValue(reader, idProperty.Name)) + "</b></td>");
Response.Write("<td align=center class=" + clas + "><b>" + string.Format(selectTempl, layer.Name, GetPropertyValue(reader, idProperty.Name)) + "</b></td>");

autonumber++;

for (int i = 0; i < reader.GetPropertyCount(); i++)
{
if (reader.GetPropertyName(i).ToLower() != geom)
{
string val = GetPropertyValue(reader, reader.GetPropertyName(i)).ToString();

if ((val.IndexOf("http") != -1 || val.IndexOf("www") != -1) && val.IndexOf("href") == -1)
{
val = "<a href=\"" + val + "\" target=_blank>" + val + "</a>";
}

Response.Write("<td align=left class=" + clas + ">" + val.Replace("\\n", "<br />") + "</td>");
}
}
Response.Write("</tr>");
Response.Flush();
}

reader.Close();
reader.Dispose();
}
catch (Exception)
{
}

Response.Write("</table></td></td>");
Response.Write("<tr><td>&nbsp;</td></tr>");
Response.Flush();
}
}

Response.Write("</table>");

 

1 REPLY 1
Message 2 of 2
reno.sun.gis
in reply to: reno.sun.gis

I found the answer in C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\mapviewernet\getselectedfeatures.aspx

 

You will need to add following codes into MultiGrid_Show.aspx to get the layer property mappings.

 

<script runat="server">
String mapName;
String sessionId;
String locale;
CultureInfo culture;
System.Text.RegularExpressions.Regex regex;

static NameValueCollection GetLayerPropertyMappings(MgResourceService resSvc, MgLayerBase layer)
{
NameValueCollection mappings = new NameValueCollection();
MgByteReader content = resSvc.GetResourceContent(layer.GetLayerDefinition());
XmlDocument doc = new XmlDocument();
doc.LoadXml(content.ToString());
XmlNodeList propNodes = doc.SelectNodes("//LayerDefinition/VectorLayerDefinition/PropertyMapping");
foreach (XmlNode propNode in propNodes)
{
String name = propNode["Name"].InnerText;
String value = propNode["Value"].InnerText;

mappings[name] = value;
}
return mappings;
}

</script>

 

 

Then, you will be able to add only the attributes that you would like to display to your users.

 

MgResourceIdentifier resId = new MgResourceIdentifier(layer.GetFeatureSourceId());
MgFeatureQueryOptions query = new MgFeatureQueryOptions();
NameValueCollection mappings = GetLayerPropertyMappings(resourceSrvc, layer);
foreach (String key in mappings.Keys)
{
query.AddFeatureProperty(key);
}

string filter = sel.GenerateFilter(layer, layer.GetFeatureClassName());
query.SetFilter(filter);

MgDataPropertyDefinition idProperty = GetIdProperty(featureService, layer);
MgFeatureReader reader = featureService.SelectFeatures(resId, layer.GetFeatureClassName(), query);

string geom = layer.GetFeatureGeometryName().ToLower();
query.AddFeatureProperty(geom);

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report