Re: [mapguide-users] Trying to create an ajax search thingo
Thanks for the heads up! That makes things a lot neater :) Hopefully I can make this available for some commenting when I'm all done :) Also, you may need to double check that you're correctly using the MgMap API as a result of http://trac.osgeo.org/mapguide/wiki/MapGuideRfc9 - Jackie -- View this message in context: http://n2.nabble.com/Trying-to-create-an-ajax-search-thingo-tp2729762p2730760.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
Re: [mapguide-users] Trying to create an ajax search thingo
I can remember seeing somewhere something taht returns all the mapped feature properties from the layer, however I can seem to remember what it was attached to FeatureReader? LayerDefinitoin? MgSelection? -- View this message in context: http://n2.nabble.com/Trying-to-create-an-ajax-search-thingo-tp2729762p2731032.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
Re: [mapguide-users] Trying to create an ajax search thingo
That would be the Layer Definition. You would have to get the resource id of the layer definition from the MgLayer and get the resource content, looking for the PropertyMapping elements (I believe). - Jackie Jamo wrote: I can remember seeing somewhere something taht returns all the mapped feature properties from the layer, however I can seem to remember what it was attached to FeatureReader? LayerDefinitoin? MgSelection? -- View this message in context: http://n2.nabble.com/Trying-to-create-an-ajax-search-thingo-tp2729762p2731956.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
Re: [mapguide-users] Trying to create an ajax search thingo
Jackie I've created a monster.. something is wrong with the FeatureReader that is produced from the layer i think? It seems to be retrieveing all features from the featuresource the layer has a filter assigned that grabs only some features from the featuresource... If you or anyone is able to have a looky it would be great ! requires ajaxcontroltoolkit. I can zip up the project if required and post it here. Default.aspx --- %@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=Searchtool_Default % %@ Register Assembly=AjaxControlToolkit Namespace=AjaxControlToolkit TagPrefix=cc1 % %@ Register Assembly=System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Namespace=System.Web.UI TagPrefix=asp % !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 titleUntitled Page/title /head body form id=form1 runat=server asp:ScriptManager ID=ScriptManager1 runat=server /asp:ScriptManager div cc1:TabContainer ID=SearchContainer runat=server ActiveTabIndex=0 cc1:TabPanel runat=server HeaderText=TabPanel1 ID=TabPanel1 Visible=False /cc1:TabPanel /cc1:TabContainer /div /form /body /html -- Default.aspx.cs -- using System; using System.Collections.Specialized; using System.Text; using System.Globalization; using OSGeo.MapGuide; using System.Web; using System.Data; using System.Collections; using System.Web.UI.WebControls; using System.Web.UI; using AjaxControlToolkit; public partial class Searchtool_Default : System.Web.UI.Page { //for testing requires input from session //change these to a local map resource internal static String mapResLocation = Library://Production/PortBris/Maps/PortBris.MapDefinition; internal static String mapName = PortBris; //define all selections for searches here //every search you generate requires a new //MGSelection to be defined here. internal static MgSelectionBase cadFeatures; internal static MgSelectionBase geoFeatures; //get selection ready for searching on protected MgSelectionBase createSelectionMaster(String[] Layers) { MapGuideApi.MgInitializeWebTier(Request.ServerVariables[APPL_PHYSICAL_PATH] + ../webconfig.ini); MgUserInformation userInfo = new MgUserInformation(Anonymous, ); MgSite site = new MgSite(); //connect to site site.Open(userInfo); String sessionId = site.CreateSession(); MgSiteConnection siteConnection = new MgSiteConnection(); //open site connection siteConnection.Open(userInfo); MgResourceService ResourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService; MgFeatureService FeatureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService; MgResourceIdentifier mgResourceID = new MgResourceIdentifier(mapResLocation); //MgMapBase map = new MgMapBase(); MgMap map = new MgMap(siteConnection); map.Create(ResourceService, mgResourceID, mapName); MgSelectionBase thisSel = new MgSelectionBase(map); foreach (String layer in Layers) { MgLayer cLayer = map.GetLayers().GetItem(layer) as MgLayer; MgFeatureReader cFeatReader = cLayer.SelectFeatures(null); thisSel.AddFeatures(cLayer as MgLayerBase, cFeatReader,0); } return thisSel; } //return an array protected String[] StringArray(String CommaSeperatedLayers) { return CommaSeperatedLayers.Split(,.ToCharArray()); } //add a DDL search type to the TabContainer protected DropDownList addSearchDDL(Control controlToAddTo, String searchDDLId, String labelText) { Label cLabel = new Label(); cLabel.Text = labelText + :; controlToAddTo.Controls.Add(new LiteralControl(BR)); controlToAddTo.Controls.Add(cLabel); DropDownList cDDL = new DropDownList(); cDDL.ID = searchDDLId; controlToAddTo.Controls.Add(cDDL); controlToAddTo.Controls.Add(new LiteralControl(BR)); controlToAddTo.Controls.Add(new LiteralControl(BR)); ListSearchExtender cSrchExt = new ListSearchExtender(); cSrchExt.TargetControlID = searchDDLId; cSrchExt.ID = searchDDLId + SrchExt; cSrchExt.IsSorted = true; controlToAddTo.Controls.Add(cSrchExt); return cDDL; } //add a new Tab to the Ajax TabContainer //each tab is a different search type protected AjaxControlToolkit.TabPanel AddTab(AjaxControlToolkit.TabContainer TabCont, String TabID, String Header) { AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel(); newTab.ID = TabID; newTab.HeaderText = Header; TabCont.Tabs.Add(newTab); TabCont.TabIndex = 1; return newTab; } protected Panel addAdvancedSearch(Control controlToAddTo, String searchName) { if (controlToAddTo.FindControl(advSrchPnl + searchName) == null) { Panel
Re: [mapguide-users] Trying to create an ajax search thingo
Perhaps you may have used the wrong MgSelection constructor? The API docs says that MgSelection() is a dummy constructor. - Jackie Jamo wrote: I'm trying to populate an Ajax TabContainer with a tab for each search. I'm getting an error for line 94: The map definition is invalid. foreach (MgLayer cLayer in cadFeatures.GetLayers()) Is it best to store the information needed for each search in a MgSelection or would it be better to extract information needed to a DataTable? I'm trying to make it as flexible as possible. hopefully adding some other search type other than just DropDownList. At the moment this runs seperate to mapguide and does not interact with the map itself (just for testing at the moment). - Default.aspx -- %@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=Searchtool_Default % %@ Register Assembly=AjaxControlToolkit Namespace=AjaxControlToolkit TagPrefix=cc1 % %@ Register Assembly=System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Namespace=System.Web.UI TagPrefix=asp % !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 titleUntitled Page/title /head body form id=form1 runat=server asp:ScriptManager ID=ScriptManager1 runat=server /asp:ScriptManager div cc1:TabContainer ID=SearchContainer runat=server ActiveTabIndex=0 cc1:TabPanel runat=server HeaderText=TabPanel1 ID=TabPanel1 Visible=False /cc1:TabPanel /cc1:TabContainer /div /form /body /html --- Default.aspx.cs --- using System; using System.Collections.Specialized; using System.Text; using System.Globalization; using OSGeo.MapGuide; using System.Web; using System.Data; using System.Collections; using System.Web.UI.WebControls; using System.Web.UI; public partial class Searchtool_Default : System.Web.UI.Page { //define all selections for searches here internal static MgSelection cadFeatures; internal static MgSelectionBase geoFeatures; //get selection ready for searching on protected MgSelection createSelectionMaster(String[] Layers) { MapGuideApi.MgInitializeWebTier(Request.ServerVariables[APPL_PHYSICAL_PATH] + ../webconfig.ini); MgUserInformation userInfo = new MgUserInformation(Anonymous, ); MgSite site = new MgSite(); //connect to site site.Open(userInfo); String sessionId = site.CreateSession(); MgSiteConnection siteConnection = new MgSiteConnection(); //open site connection siteConnection.Open(userInfo); MgResourceService ResourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService; MgFeatureService FeatureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService; MgResourceIdentifier mgResourceID = new MgResourceIdentifier(Library://Production/PortBris/Maps/PortBris.MapDefinition); MgMap map = new MgMap(); map.Create(ResourceService, mgResourceID, PortBris); MgSelection thisSel = new MgSelection(); foreach (String layer in Layers) { MgLayer cLayer = map.GetLayers().GetItem(layer) as MgLayer; string layerClassName = cLayer.GetFeatureClassName(); string selectionString = thisSel.GenerateFilter(cLayer, layerClassName); string layerFeatureId = cLayer.GetFeatureSourceId(); MgResourceIdentifier layerFeatureResource = new MgResourceIdentifier(layerFeatureId); MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions(); queryOptions.SetFilter(selectionString); MgFeatureReader cFeatReader = FeatureService.SelectFeatures(layerFeatureResource, layerClassName, queryOptions); thisSel.AddFeatures(cLayer as MgLayerBase, cFeatReader, -1); } return thisSel; } //return an array protected String[] StringArray(String CommaSeperatedLayers) { return CommaSeperatedLayers.Split(,.ToCharArray()); } //add a DDL search type to the TabContainer //ToDo: add list search capabilities and filtering protected DropDownList addSearchDDL(Control controlToAddTo, String searchDDLId, String labelText) { Label cLabel = new Label(); cLabel.Text = labelText; controlToAddTo.Controls.Add(cLabel); DropDownList cDDL = new DropDownList(); cDDL.ID = searchDDLId; controlToAddTo.Controls.Add(cDDL); return cDDL; } //add a new Tab to the Ajax TabContainer //each tab is a different search type protected AjaxControlToolkit.TabPanel AddTab(AjaxControlToolkit.TabContainer TabCont, String TabID, String Header) { AjaxControlToolkit.TabPanel newTab = new AjaxControlToolkit.TabPanel(); newTab.ID = TabID; newTab.HeaderText = Header; TabCont.Tabs.Add(newTab);
Re: [mapguide-users] Trying to create an ajax search thingo
Cheers Jackie I've fixed it up changed the MgSelection to MgSelectionBase where needed. Also changed the MgSelection thisSel = new MgSelection() to MgSelectionBase thisSel = new MgSelectionBase(map); which i think has fixed up the issue Another issue thats got me stunned is this doesn't work.. foreach (MgLayerBase cLayer in cadFeatures.GetLayers()) { Response.Write(cLayer.GetClassDefinition().GetProperties().Count); } However at the same point in code this does? string layerClassName = cLayer.GetFeatureClassName(); string selectionString = cadFeatures.GenerateFilter(cLayer, layerClassName); string layerFeatureId = cLayer.GetFeatureSourceId(); MgResourceIdentifier layerFeatureResource = new MgResourceIdentifier(layerFeatureId); MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions(); queryOptions.SetFilter(selectionString); MgFeatureReader featureReader = FeatureService.SelectFeatures(layerFeatureResource, layerClassName, queryOptions); Response.Write(featureReader.GetClassDefinition().GetProperties().Count); I'm not too sure on why or how but I'm not too fussed unless this extra creation of a MgSelection Set will cause twice as much waiting Jackie Ng wrote: Perhaps you may have used the wrong MgSelection constructor? The API docs says that MgSelection() is a dummy constructor. - Jackie -- View this message in context: http://n2.nabble.com/Trying-to-create-an-ajax-search-thingo-tp2729762p2729958.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
Re: [mapguide-users] Trying to create an ajax search thingo
Also, you may need to double check that you're correctly using the MgMap API as a result of http://trac.osgeo.org/mapguide/wiki/MapGuideRfc9 - Jackie Jamo wrote: Cheers Jackie I've fixed it up changed the MgSelection to MgSelectionBase where needed. Also changed the MgSelection thisSel = new MgSelection() to MgSelectionBase thisSel = new MgSelectionBase(map); which i think has fixed up the issue Another issue thats got me stunned is this doesn't work.. foreach (MgLayerBase cLayer in cadFeatures.GetLayers()) { Response.Write(cLayer.GetClassDefinition().GetProperties().Count); } However at the same point in code this does? string layerClassName = cLayer.GetFeatureClassName(); string selectionString = cadFeatures.GenerateFilter(cLayer, layerClassName); string layerFeatureId = cLayer.GetFeatureSourceId(); MgResourceIdentifier layerFeatureResource = new MgResourceIdentifier(layerFeatureId); MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions(); queryOptions.SetFilter(selectionString); MgFeatureReader featureReader = FeatureService.SelectFeatures(layerFeatureResource, layerClassName, queryOptions); Response.Write(featureReader.GetClassDefinition().GetProperties().Count); I'm not too sure on why or how but I'm not too fussed unless this extra creation of a MgSelection Set will cause twice as much waiting Jackie Ng wrote: Perhaps you may have used the wrong MgSelection constructor? The API docs says that MgSelection() is a dummy constructor. - Jackie -- View this message in context: http://n2.nabble.com/Trying-to-create-an-ajax-search-thingo-tp2729762p2730027.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