[mapguide-users] Storing WebLayout in Session Repository

Gunter Becker gunter.becker at CSOGIS.DE
Thu Feb 22 07:01:43 EST 2007


So I think the steps I have to perform are:

  - Store the original MapDefinition in Session Repository (make a copy)
  - Make a reference to the users Map in Session Repository
  - loop through all the layers in the Map to get all the properties like
for example the visibility of a layer
  - Modify the copy of the MapDefinition with this properties
  - Call AjaxViewer with stored WebLayout and the modified MapDefinition

Does anyone agree with me?
If so then it's a bigger job than I've first thought.

Isn't there a method somewhere to make a new MapDefinition out of a Map?




I have to store the original MapDefinition which was first called with the
WebLayout into the session repository and then try to iterate through the
layers collection of the Map to modify the


Hidekazu Shimaji wrote:
> 
> Hello,
> 
> Not "NeulingenALK.Map" but "NeulingenALK.MapDefinition" is required for
> the WebLayout.
> I tried the same way of you, but it did not work.
> I don't know why.  I finally gave up using the MgMap class, 
> and used the SetResource function for setting a xml of the MapDefinition.
> 
> Does anybody know about it?
> 
> Regards,
> Hidekazu Shimaji
> 
> --- Gunter Becker <gunter.becker at CSOGIS.DE> wrote:
> 
>> 
>> OK your code works for me but now I got the problem that the map isn't
>> shown
>> in the AjaxViewer. Instead I got hte following error message:
>> 
>>   An unclassified exception occurred. Exception occurred in method
>> MgMap_Create__SWIG_0 at line 681 in file .\MgApi_wrap.cpp
>> 
>> My Query to launch AjaxViewer:
>> 
>>  
>>
> http://geo19/mapguide/mapviewerajax/?SESSION=bb143bae-ffff-ffff-8000-000476dc3d5a_en&amp;WEBLAYOUT=Session:bb143bae-ffff-ffff-8000-000476dc3d5a_en//Current.WebLayout
>> 
>> XML representation of the WebLayout:
>> 
>>   <?xml version="1.0" encoding="utf-8" ?> 
>>   <WebLayout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xsi:noNamespaceSchemaLocation="WebLayout-1.0.0.xsd">
>>       <Title>ALK Neulingen</Title> 
>>       <Map>
>>          
>> <ResourceId>Session:279a9b8c-0000-1000-8000-000476dc3d5a_en//NeulingenALK.Map</ResourceId>
>> 
>>           <HyperlinkTarget>TaskPane</HyperlinkTarget> 
>>       </Map>
>>       ...
>> 
>> Must the <ResourceId> be of Type "MapDefinition" or is "Map" also OK?? 
>> 
>> To make things clear:
>> 
>> My intention is to store the WebLayout into the session repository to
>> give
>> the user the ability to leave the AjaxViewer and go to another webpage of
>> my
>> application and then return to the AjaxViewer. All of the changes he had
>> done before leaving the map (changing colors, adding layers, ..) should
>> be
>> avbailable after loading WebLayout stored in session.
>> 
>> Is that the right way to this ??
>> 
>> 
>> Hidekazu Shimaji wrote:
>> > 
>> > Hello,
>> > 
>> > I don't think the ResourceHeader is the cause.
>> > You have to set the content of xmlWebLayout to byteArray.
>> > 
>> > How about do like this:
>> > 
>> > --- the code start
>> > //save the xml to MemoryStream
>> > System.IO.MemoryStream stream = new System.IO.MemoryStream();
>> > xmlWebLayout.Save(stream);
>> > // get byte array from the MemoryStream
>> > byte[] byteArray = stream.ToArray();
>> > //convert byte array to string without the first byte(BOM)
>> > string outerXml = System.Text.Encoding.UTF8.GetString(byteArray, 1,
>> > byteArray.Length - 1);
>> > // convert string to byte array with the utf-8 encoding 
>> > byteArray = System.Text.Encoding.UTF8.GetBytes(outerXml);
>> > 
>> > // store the WebLayout in Session-Repository
>> > MgByteSource byteSource = new MgByteSource(byteArray,
>> >    byteArray.Length);
>> > byteSource.MimeType = MgMimeType.Xml;
>> > MgResourceIdentifier userWebLayoutId = new
>> >     MgResourceIdentifier("Session:" + sessionId + @"//Current." +
>> >     MgResourceType.WebLayout);
>> > 
>> > resourceService.SetResource(userWebLayoutId, byteSource.GetReader(),
>> > null);
>> > --- the code end
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9096652
>> 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/Storing-WebLayout-in-Session-Repository-tf3265925s16610.html#a9098651
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list