<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
IMO, the confusing part is that there are multiple things that are
called a "layer"<br>
1) LayerDefinition, this is an xml resource, just like a MapDefinition
or a WebLayout<br>
2) MapLayer, this is a part of a MapDefinition and references a
LayerDefinition<br>
3) Runtime MapLayer, this is a binary copy of (2), but detached from
the MapDefinition, still references a LayerDefinition<br>
<br>
The MapGuide API has methods for dealing with the runtime map.<br>
It only has SetResource and GetResource calls for dealing with the
resources.<br>
These calls get and set xml data respectively.<br>
<br>
This means that you have to parse and update xml manually.<br>
I find this to be a non-trivial task, which is why I created the
MaestroAPI,<br>
and put in classes that deal with the xml.<br>
<br>
To save a LayerDefinition as a temp resource, do this:<br>
string sessionId; //Initialize somewhere<br>
MgResourceService srv; //Initialize somewhere<br>
string xml =
srv.GetResourceContent("Library://.....Layer.LayerDefinition");<br>
//Manipulate xml<br>
string randomName = Guid.NewGuid().ToString(); //Use random name to
avoid overwrites<br>
string tmpId = "Session:" + sessionId + "//" + randomName +
".LayerDefinition";<br>
srv.SetResourceContent(xml, tmpId);<br>
<br>
Unfortunately the GetResource and SetResource won't work like above.<br>
Search the forums for details.<br>
<br>
This page explains how to modify the filter, using the MaestroAPI (only
for .Net):<br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/ModifyLayerFilter">http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/ModifyLayerFilter</a><br>
<br>
This page explains the same, but BEFORE the viewer loads:<br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/AddInitialLayer">http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/AddInitialLayer</a><br>
<br>
<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
<br>
prbabu skrev:
<blockquote cite="mid:1248917230171-3353695.post@n2.nabble.com"
 type="cite">
  <pre wrap="">Hi Kenneth,
     Can I say, the below step:
3) Save the LayerDefinition to a temp name (in the Session repository) 
means create a "new" MgLayer and then add the same to the layer collection?

If yes, what about replacing the existing layer's filter? Do we need to
delete 
the existing one and create a new temporary one with the same layer name?

There has been numerous conversations on layer filtering, unfortunately
could
n't really pin on a particular one and say this is the solution. May be need
a
"correct code" in the code sample page of MGOS. I work on .NET API.

Thanks for your time.

Regards,
Praveen 




Kenneth Skovhede, GEOGRAF A/S wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">There are only few examples of Java code avalible.

These are the steps to perform, regardless of programming language:

1) Obtain the LayerDefinition xml
2) Update the &lt;Filter&gt; tag
3) Save the LayerDefinition to a temp name (in the Session repository)
4) Get a reference to the Runtime map (MgMap.Open)
5) Update the runtime map's layer to point to the temp resource created 
in (3)
6) Save the runtime map
7) Refresh the client


If you want to modify the layer filter BEFORE the viewer loads, you need 
to do this:

1) Obtain the LayerDefinition xml
2) Update the &lt;Filter&gt; tag
3) Save the LayerDefinition to a temp name (in the Session repository)
4) Obtain the MapDefinition.xml
5) Update the MapDefinition's layer to point to the temp resource 
created in (3)
6) Save the MapDefinition to a temp name (in the Session repository)
7) Obtain the WebLayout/ApplicationDefinition xml
8) Update the Map/ResourceId to point to the temp resource created in (6)
9) Save the WebLayout/ApplicationDefinition to a temp name (in the 
Session repository)
10) Open the viewer and point to the temp resource created in (9)

If any of the steps cause you trouble, ask again.

Regards, Kenneth Skovhede, GEOGRAF A/S



Jai Prakash Mansukhani skrev:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi all,
I have a map with a layer that is being populated from x/y coordinates
from an MySQL server table and want to be able to dynamically add a
filter to the layer. i.e. filter the data based on who is logged in.

I read a few post on this topic before but i was not able to 
understand the concept with satisfactory.

It would very kind of you if somebody can provide me with some piece 
of code.

Thanks and Regards,
Jai Mansukhani



_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>