[mapguide-users] how to set selected feature at client in fusion???

foolfish xjimmyshcn at sohu.com
Mon Jun 9 21:52:54 EDT 2008


thanks for reply~ Berdel

i meet the same problem after use SetSelectionXML() at client.
i think the selection.ToXml() at server has problem in fusion,perhaps the
format is not valid for fusion.



Berdel, Brian wrote:
> 
> There are two ways to do it...My preferred way is to use the
> MapguideViewweAPI.js file located under
> fusion/MapGuide/MapGuideViewerAPI.js
> 
> This has the SetSelectionXML Function in it and it also automatically
> zooms and refreshes the map once called.   Place this javascript in your
> task frame page.  I include the MapGuideViewerAPI.js in my fusion
> application template.
> 
>   
> 
>       function GetParent()
> 
> {
> 
>   if (popup) {
> 
>       return opener;
> 
>     } else 
> 
>     if (parent.Fusion) {
> 
>         return parent;
> 
>     } else if (parent.parent.Fusion) {
> 
>         return parent.parent;
> 
>     }
> 
>     return null;
> 
> }
> 
>  
> 
> function(mapName, sel)
> 
> {
> 
> var map = GetParent().Fusion.getMapByName(mapName); 
> 
> GetParent().SetSelectionXML(sel);
> 
> }
> 
>  
> 
> The one issue I did run into is that when grabbing the selectionXML
> 
>  
> 
> selectionXML = selection.ToXml();
> 
>  
> 
> the XML was incorrect...For the layername it was bringing in only the
> second part of the layer name (i.e. Parcels instead of Default:Parcels)
> which was giving an error in fusion when setting the selection.   For
> right now, I am just replacing the string after calling selection.ToXML
> 
>  
> 
>  
> 
> There is also a setSelection() function in fusion, but I haven't tried it
> yet...
> 
>  
> 
> Thanks, 
> 
>  
> 
> Brian  Berdel 
> 
> McMahon Associates, Inc. 
> 
> p: 215.283.9444
> 
> www.mcmtrans.com 
> 
> -----Original Message-----
> From: mapguide-users-bounces at lists.osgeo.org
> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of foolfish
> Sent: Sunday, June 08, 2008 10:17 PM
> To: mapguide-users at lists.osgeo.org
> Subject: [mapguide-users] how to set selected feature at client in
> fusion???
> 
>  
> 
>  
> 
> my problem is in tradition method (not use fusion), i can select feature
> at
> 
> server, and display the selected feature at client。
> 
>  
> 
> but in fusion,the follow line is failed:
> 
> parent.parent.SetSelectionXML(selectionXML);  
> 
> parent.parent.mapFrame.Refresh();
> 
>  
> 
> my question is how to setSelection at client in fusion?:confused:
> 
>  
> 
> -------------------------------------------------------------
> 
> [at server]:i define a function to select Feature,and return a
> selectionXML    
> 
> public void CreateSelectionXML(String queryLayer, String
> queryString,String
> 
> map_name)
> 
>     {
> 
>         MgResourceService resService =
> 
> (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
> 
>         MgFeatureService featureService =
> 
> (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
> 
>       MgMap map = new MgMap();
> 
>         map.Open(resService, map_name);
> 
>         MgLayer layer = (MgLayer)map.GetLayers().GetItem(queryLayer);
> 
>       MgResourceIdentifier resId = new
> 
> MgResourceIdentifier(layer.GetFeatureSourceId());
> 
>         MgFeatureQueryOptions queryOption = new MgFeatureQueryOptions();
> 
>         queryOption.SetFilter(queryString);
> 
>         MgFeatureReader featureReader =
> featureService.SelectFeatures(resId,
> 
> queryLayer, queryOption);
> 
>       MgSelection selection = new MgSelection(map);
> 
>         selection.AddFeatures(layer, featureReader, 0); 
> 
>         OutputSelectionInHTML(selection, featureService, queryLayer);
> 
>         selectionXML = selection.ToXml();
> 
>     }
> 
>  
> 
> -------------------------------------------------------------
> 
> [at client]:
> 
> <%
> 
>     string sessionID = Request.Form.Get("SESSION");;
> 
>      String queryString = "ID='"+ Request.Form.Get("ID"); +"'";
> 
>      String queryLayer =  Request.Form.Get("LAYER_NAME");
> 
>      String map_name = Request.Form.Get("MAP_NAME");
> 
>  
> 
>      InitializeWebTier(Request);
> 
>      onnectToServer(sessionID);
> 
>      CreateSelectionXML(queryLayer,queryString,map_name );
> 
>      String selectionXML = utility.SelectionXML;
> 
> %>
> 
> ...
> 
> <script type="text/javascript" >
> 
>         function onPageLoad() {
> 
>             var selectionXML = '<% = selectionXML  %>';
> 
>             parent.parent.SetSelectionXML(selectionXML);         
> 
>         }
> 
> parent.parent.SetSelectionXML(selectionXML);  
> 
> parent.parent.mapFrame.Refresh();
> 
>  
> 
> </script>
> 
> ...
> 
> <body onload="onPageLoad()" >
> 
> ...
> 
> </body>
> 
> -------------------------------------------------------------
> 
>  
> 
>  
> 
> -- 
> 
> View this message in context:
> http://www.nabble.com/how-to-set-selected-feature-at-client-in-fusion----tp17725343p17725343.html
> 
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> 
>  
> 
> _______________________________________________
> 
> mapguide-users mailing list
> 
> mapguide-users at lists.osgeo.org
> 
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-set-selected-feature-at-client-in-fusion----tp17725343p17746181.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list