[mapguide-users] Re: Load different map in weblayout - Basic viewer

tmblackflag steve.calpoly at gmail.com
Fri Oct 7 13:15:41 EDT 2011


I have a single web layout and dynamically change the map as well. The
general idea is to copy the web layout to the session repository, then edit
the XML to point to a different map. Then in your page that has the viewer
simply point the URL to the session map. 

floor1 = 'myNewMapName';

InitializeWebTier();
        MgUserInformation userInfo = new MgUserInformation(defaultUser,
defaultPassword);
        MgSiteConnection siteConnection = new MgSiteConnection();
        siteConnection.Open(userInfo);
        MgSite site = siteConnection.GetSite();
        sessionId = site.CreateSession();

        MgResourceService resourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
        MgByteReader rd = resourceService.GetResourceContent(new
MgResourceIdentifier("Library://MILP/Layout/MILP.WebLayout"));
        XmlDocument doc = new XmlDocument();
        doc.PreserveWhitespace = true;
        doc.LoadXml(rd.ToString());
        doc.GetElementsByTagName("ResourceId").Item(0).InnerText =
"Library://MILP/" + floor1 + "/Maps/" + floor1 + ".MapDefinition";
        MgResourceIdentifier newLayout = new MgResourceIdentifier("Session:"
+ sessionId + "//basic.WebLayout");
        resourceService.SetResource(newLayout, new
MgByteReader(doc.OuterXml, "text/xml"), null);
        
      

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Load-different-map-in-weblayout-Basic-viewer-tp6869814p6870193.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list