how to set selected feature at client in fusion???

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

how to set selected feature at client in fusion???

xjimmyshcn
ENV: mapguide open source 2.0.1 + mapguide studio 2009 + visual studio 2005(c#)

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?


the follow code is the traditional method:
-------------------------------------------------------------
[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 <b>onPageLoad</b>() { var <b>selectionXML </b>= '<% = <b>selectionXML </b>%>'; parent.parent.SetSelectionXML(selectionXML); } parent.parent.SetSelectionXML(<b>selectionXML</b>); parent.parent.mapFrame.Refresh(); </script>...
<body onload="<b>onPageLoad()" >
...
</body>
-------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: how to set selected feature at client in fusion???

Paul Spencer
Hi,

Fusion works with selections somewhat differently, you should be able  
to just save() the selection on the server side and Fusion will pick  
it up (at least that is how the query stuff works).

I believe Mike did add something for selection xml but I don't know  
what it was - perhaps he will comment :)

Cheers

Paul

On 8-Jun-08, at 10:17 PM, foolfish wrote:

>
> 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
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: how to set selected feature at client in fusion???

Berdel, Brian
In reply to this post by xjimmyshcn

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: [hidden email] [mailto:[hidden email]] On Behalf Of foolfish
Sent: Sunday, June 08, 2008 10:17 PM
To: [hidden email]
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 fusionthe 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 Featureand 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

[hidden email]

http://lists.osgeo.org/mailman/listinfo/mapguide-users


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: how to set selected feature at client infusion???

Berdel, Brian

FYI, you do not need

 

var map = GetParent().Fusion.getMapByName(mapName);

 

That was in there for a different function…

 

Brian


From: [hidden email] [mailto:[hidden email]] On Behalf Of Berdel, Brian
Sent: Monday, June 09, 2008 10:26 AM
To: MapGuide Users Mail List
Subject: RE: [mapguide-users] how to set selected feature at client infusion???

 

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: [hidden email] [mailto:[hidden email]] On Behalf Of foolfish
Sent: Sunday, June 08, 2008 10:17 PM
To: [hidden email]
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 fusionthe 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 Featureand 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

[hidden email]

http://lists.osgeo.org/mailman/listinfo/mapguide-users


_______________________________________________
mapguide-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: how to set selected feature at client in fusion???

xjimmyshcn
In reply to this post by Paul Spencer
at server in CreateSelectionXML() ,i add  the following line:
selection.Save(resService, map_name);

at client i  use the following line to refresh the map:
parent.document.getElementById('Map').widget.aMaps[0].drawMap();

then it's OK。

thank's a lot, Paul~

Paul Spencer-5 wrote
Hi,

Fusion works with selections somewhat differently, you should be able  
to just save() the selection on the server side and Fusion will pick  
it up (at least that is how the query stuff works).

I believe Mike did add something for selection xml but I don't know  
what it was - perhaps he will comment :)

Cheers

Paul

On 8-Jun-08, at 10:17 PM, foolfish wrote:

>
> 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@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: how to set selected feature at client in fusion???

xjimmyshcn
In reply to this post by Berdel, Brian
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, or the schema file FeatureSet-1.0.0.xsd 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@lists.osgeo.org [mailto:mapguide-users-bounces@lists.osgeo.org] On Behalf Of foolfish
Sent: Sunday, June 08, 2008 10:17 PM
To: mapguide-users@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@lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapguide-users


_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

Re: how to set selected feature at client in fusion???

xjimmyshcn
In reply to this post by Paul Spencer
oh~ it brought new problems:

the first time i select the feature , it's quite normal.
but it's abnormal after i make a new selection.

how to clear the previous selection?



-------------------------------------------------------------------
Paul Spencer-5 wrote
Hi,

Fusion works with selections somewhat differently, you should be able  
to just save() the selection on the server side and Fusion will pick  
it up (at least that is how the query stuff works).

I believe Mike did add something for selection xml but I don't know  
what it was - perhaps he will comment :)

Cheers

Paul

On 8-Jun-08, at 10:17 PM, foolfish wrote:

>
> 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@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
Reply | Threaded
Open this post in threaded view
|

RE: how to set selected feature at client in fusion???

alba
In reply to this post by Berdel, Brian
hi Bernel Brian,
You excuse me for this email, but I have the problem to select and to selection objects on map

I use mgos 2.0.1 with IIS and fusion
I insert in fusion/MapGuide/MapGuideViewerApi.js

function GetParent(){
  if (popup) {
      return opener;
    } else
    if (parent.Fusion) {
        return parent;
    } else if (parent.parent.Fusion) {
        return parent.parent;
    }
    return null;
}

In my procedure I insert

<script language="javascript" src="../../fusion/MapGuide/MapGuideViewerApi.js"></script>
...
function Selezione_oggetto(){

var resultSelect = document.getElementById("resultSelect");
var k=0;
var valoreCercato=dati_ord[resultSelect.value];
while(valoreCercato!=dati[k]){
  k=k+1;
  }
            //alert(k);
            reqParams = "COMMAND=GETSELECTIONXML";
                        reqParams += "&SESSION=" + encodeURIComponent(session);
            reqParams += "&MAPNAME=" + encodeURIComponent(mapName);
                        reqParams += "&LAYERNAME=" + encodeURIComponent("Catastali");
                        reqParams += "&IDLIST=" + results[k].idList.toJSONString();
            if (msie)
                reqHandler = new ActiveXObject("Microsoft.XMLHTTP");
            else
                reqHandler = new XMLHttpRequest();

            reqHandler.open("POST", "querycontroller.php", false);
            reqHandler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                        reqHandler.send(reqParams);
                        selectionXml = reqHandler.responseText;
            alert(mapName);

// ?????????? problem----------------------

//parent.parent.mapFrame.SetSelectionXML(TrimString(selectionXml));// old for mg 1.2

var map = GetParent().Fusion.getMapByName(mapName);  // ??????????

GetParent().SetSelectionXML(selectionXml);// ??????????
}


function Zoom_oggetto()
{//alert("ZoomToFeature");
var resultSelect = document.getElementById("resultSelect");
var scaleInput = document.getElementById("scaleInput");
scale = scaleInput.value;
scale = (scale == 0) ? 10000 : scale;
scale = scale*1.0;
var k=0;
var valoreCercato=dati_ord[resultSelect.value];
while(valoreCercato!=dati[k]){
    k=k+1;
  }

feature = results[k];

// ?????????? problem----------------------
parent.parent.mapFrame.ZoomToView(feature.centerX, feature.centerY, scale, true);// ??????????
}

Can you help me, please?

Thank Alba