http://osgeo-org.1560.n6.nabble.com/file/n4879170/MapGuideSample.zip MapGuideSample.zip Hi all,
I'm testing beta 2.4 and I'm experimenting an error on AjaxViewer SetSelectionXML(). If I execute, nothing is selected. I've built a very simple task pane I have set as initial URL in my basic WebLayout. If I follow with debugger, I can see that selection.ToXml() seems working properly. But as a result of executing Java Script, I get ther right zoom to the right region, but nothing is selected. The same code for Mapguide 2.2 woked properly. Anybody have any idea if something is changed?... Best regards ---------------------------------------------------------------------------------------------------------- *Task.aspx* ---------------------------------------------------------------------------------------------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Task.aspx.cs" Inherits="MapGuideSample.Task" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Zoom to" /> </div> </form> </body> </html>/ ---------------------------------------------------------------------------------------------------------- *Task.aspx.cs* ---------------------------------------------------------------------------------------------------------- /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 defaultUser = "Administrator"; string defaultPassword = "admin"; string layerName = "Collettore"; string queryString = "FID = 19216"; try { //init MG OSGeo.MapGuide.MapGuideApi.MgInitializeWebTier(@"C:\trash\MapGuideSample\MapGuideSample\webconfig.ini"); //open connection MgSiteConnection siteConnection = new MgSiteConnection(); MgUserInformation userInfo = new MgUserInformation(defaultUser, defaultPassword); siteConnection.Open(userInfo); MgResourceService resService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService); MgFeatureService featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService); MgMap map = new MgMap(); MgResourceIdentifier mapDefinition = new MgResourceIdentifier(mapName); map.Create(resService, mapDefinition, "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-tp4879170p4879170.html Sent from the MapGuide Users mailing list archive at Nabble.com. _______________________________________________ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users