[mapguide-users] Help regarding to set filter for a layer programmatically using Java

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Thu Jul 30 03:32:33 EDT 2009


Yes, I mean the GetResourceContent().

I think the main objection to sending out MaestroAPI as a part of MapGuide,
would be that it favorizes .Net over PHP and Java.

If you use the MaestroAPI http method, it should be fully server version
ignorant, so you can use it with any MGE version.

The LocalNative connection offers better performance, but you need
to sign the assembly shipped by MapGuide, and add assembly rebinding.
See this post:
http://n2.nabble.com/MaestroAPI-Comapatibility-tp3315692p3332632.html

I won't do that for MGE versions, and unfortunately the MGOS 2.1 is heavily
delayed, so I can't even provide a version for that (which would also 
work with MGE).

I was a bit slow on implementing the 1.3.0 LayerDefinition, and 
unfortunately
Studio auto upgrades your layers when you save them, causing some 
Maestro stuff
to break.

Regards, Kenneth Skovhede, GEOGRAF A/S



prbabu skrev:
> Thanks for your time, Kenneth.
> I believe the API you are referring below is SetResourceContent() and
> GetResourceContent()?
>
> "......The MapGuide API has methods for dealing with the runtime map.
> It only has SetResource and GetResource calls for dealing with the
> resources.
> These calls get and set xml data respectively."
>
>   If the Maestro API is shipped as part off the standard .NET Web Server
> Extensions API, that 
> would make like easier. I am with MGE and every new release, there is an
> inherent concern
> whether the Maestro API can work along with updated MGE version. Also, it
> gives the
> impression that it has the "core" product support, which is quite critical,
> IMO. 
> Hopefully, someone is thinking this way there.......Additionally, you will
> have less traffic in this 
> forum on repetition of questions.
>    My opinion, the APIs are highly extendable but not intuitive enough to be
> used with ease, 
> esp. when compared to my experience with MG 6.5. The Maestro API fills the
> gap to a certain extent.
>
> -Praveen
>
>
>
> Kenneth Skovhede, GEOGRAF A/S wrote:
>   
>> IMO, the confusing part is that there are multiple things that are 
>> called a "layer"
>> 1) LayerDefinition, this is an xml resource, just like a MapDefinition 
>> or a WebLayout
>> 2) MapLayer, this is a part of a MapDefinition and references a 
>> LayerDefinition
>> 3) Runtime MapLayer, this is a binary copy of (2), but detached from the 
>> MapDefinition, still references a LayerDefinition
>>
>> The MapGuide API has methods for dealing with the runtime map.
>> It only has SetResource and GetResource calls for dealing with the 
>> resources.
>> These calls get and set xml data respectively.
>>
>> This means that you have to parse and update xml manually.
>> I find this to be a non-trivial task, which is why I created the
>> MaestroAPI,
>> and put in classes that deal with the xml.
>>
>> To save a LayerDefinition as a temp resource, do this:
>> string sessionId; //Initialize somewhere
>> MgResourceService srv; //Initialize somewhere
>> string xml =
>> srv.GetResourceContent("Library://.....Layer.LayerDefinition");
>> //Manipulate xml
>> string randomName = Guid.NewGuid().ToString(); //Use random name to 
>> avoid overwrites
>> string tmpId = "Session:" + sessionId + "//" + randomName + 
>> ".LayerDefinition";
>> srv.SetResourceContent(xml, tmpId);
>>
>> Unfortunately the GetResource and SetResource won't work like above.
>> Search the forums for details.
>>
>> This page explains how to modify the filter, using the MaestroAPI (only 
>> for .Net):
>> http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/ModifyLayerFilter
>>
>> This page explains the same, but BEFORE the viewer loads:
>> http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/AddInitialLayer
>>
>>
>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>
>>
>>
>> prbabu skrev:
>>     
>>> 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:
>>>   
>>>       
>>>> 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 <Filter> 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 <Filter> 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:
>>>>     
>>>>         
>>>>> 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
>>>>> 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
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>>
>>     
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090730/cd71161d/attachment.html


More information about the mapguide-users mailing list