Hi!<div><br></div><div>I'm trying to highlight features in the map based on querystring variables. </div><div>I.e surfing to <a href="http://url.to.server?value=123456&field=FNR" target="_blank">http://url.to.server?value=123456&field=FNR</a> should highlight features with FNR=123456.</div>
<div><br></div><div>Server-side logic as follows (C#, <a href="http://asp.net" target="_blank">asp.net</a> 2.0, in Default.aspx.cs, Page_Load-function):</div><div><br></div><div><div>if (!IsPostBack) {</div><div><br></div>
<div> if (Request.QueryString.Count > 0) {</div>
<div> string sessId = Session["MapGuideSessId"] as string;</div><div> MgSiteConnection siteConn = new MgSiteConnection();</div><div> siteConn.Open(new MgUserInformation(sessId));</div>
<div> string mapName = "MapName";</div><div> MgMap map = new MgMap(siteConn);</div><div><br></div><div> /* Need to create a new map? </div><div> map.Create(new MgResourceIdentifier("Library://mapname/Mapname.MapDefinition"), mapName);</div>
<div> map.Save();</div><div> map.Open(siteConn.CreateService(MgServiceType.ResourceService) as MgResourceService, mapName);</div><div> */</div><div><br></div><div>
map.Open(siteConn.CreateService(MgServiceType.ResourceService) as MgResourceService, mapName);</div>
<div> MgLayerBase layer = map.GetLayers().GetItem(0);</div><div> StringBuilder query = new StringBuilder();</div><div> MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions();</div>
<div><br></div><div> /*Constructing up a selection string. Don't mind this. */</div><div> string filterField = GetQueryStringValue("field");</div><div> string value = GetQueryStringValue("value");</div>
<div> string[] filterVal = value.Split('|');</div><div><br></div><div> int fnrLen = filterVal.Length;</div><div><br></div><div> for (int i = 0; i < fnrLen; i++) {</div>
<div> if (i < fnrLen - 1)</div><div> query.Append(string.Format("{0} = {1} or", filterField, filterVal[i]));</div><div> else</div><div>
query.Append(string.Format("{0} = {1}", filterField, filterVal[i]));</div><div> }</div><div> </div><div> queryOptions.SetFilter(query.ToString());</div>
<div><br></div><div> MgFeatureReader reader = layer.SelectFeatures(queryOptions);</div><div> MgSelection selection = new MgSelection(map);</div><div> selection.AddFeatures(layer, reader, 0);</div>
<div> _selectionXml = selection.ToXml();</div><div> selection.Save(siteConn.CreateService(MgServiceType.ResourceService) as MgResourceService, mapName);</div><div> }</div>
<div> else {</div><div> // Utils-class sets up and creates session</div><div> utils = new Utils(Request.ServerVariables["APPL_PHYSICAL_PATH"]);</div><div> // Store session globally</div>
<div> Session["MapGuideSessId"] = utils.SessionID;</div><div> </div><div> }</div></div><div><br></div><div>When I run this code nothing gets highlighted in the map at all. I've debugged the code to make sure that the query works as intended and it does. I'm guessing that my problem has something to do with the map but I can't figure out what's wrong.</div>
<div>I'm using pretty much the same code when creating a selection from the taskpane and that works like a charm.</div><div>I've been struggeling with this for several days now and I'd be very glad if someone could help me, or at least point me in the right direction. </div>
<div>Thank you!</div><div><br></div><div>Regards,</div><div>Andreas</div><div><br></div>