[mapguide-users] Re: Mapguide beta 2.4: AjaxViewer
SetSelectionXML() seems not working
Franz1965
fsozzi at INTERCAD.CH
Fri Apr 13 13:32:09 EDT 2012
Just a note to tell that I've also tried to modifiy Task.aspx.cs to get and
use original session id without creating a new one. Also in that case it
does not work.
The code is here:
----------------------------------------------------------------------------------------------------------
* Task.aspx*
----------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using OSGeo.MapGuide;
namespace MapGuideSample
{
public partial class Task : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string mapName =
@"Library://TBDemoMesoccoCan/Default.MapDefinition";
string layerName = "Collettore";
string queryString = "FID = 19216";
try
{
//init MG
OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(@"C:\trash\MapGuideSample\MapGuideSample\webconfig.ini");
//open connection
*string mapguideSessionId =
Request.QueryString.Get("SESSION");*
MgSiteConnection siteConnection = new MgSiteConnection();
*MgUserInformation userInfo = new
MgUserInformation(mapguideSessionId);*
siteConnection.Open(userInfo);
MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgFeatureService featureService =
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
MgMap map = new MgMap();
*map.Open(resService, "Default");*
//get layer res id
MgLayer layer = (MgLayer)map.GetLayers().GetItem(layerName);
MgResourceIdentifier resId = new
MgResourceIdentifier(layer.GetFeatureSourceId());
//build query option
MgFeatureQueryOptions queryOption = new
MgFeatureQueryOptions();
queryOption.SetFilter(queryString);
//get selection
MgFeatureReader featureReader =
featureService.SelectFeatures(resId, layer.GetFeatureClassName(),
queryOption);
MgSelection selection = new MgSelection(map);
selection.AddFeatures(layer, featureReader, 0);
//get XML from selection
string selectionXML = selection.ToXml();
//get center
double selectionCenterX =
selection.GetExtents(featureService).GetLowerLeftCoordinate().GetX() +
selection.GetExtents(featureService).GetWidth() / 2;
double selectionCenterY =
selection.GetExtents(featureService).GetLowerLeftCoordinate().GetY() +
selection.GetExtents(featureService).GetHeight() / 2;
//build javascript
StringBuilder onLoadJScript = new StringBuilder();
onLoadJScript.Append("
");
//execute javascript
ClientScript.RegisterStartupScript(this.GetType(),
"StartupScript", onLoadJScript.ToString());
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Mapguide-beta-2-4-AjaxViewer-SetSelectionXML-seems-not-working-tp4879170p4879303.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list