I'm attempting at changing the map within the weblayout of the basic viewer. I've went through some similar posts that have common functionality within them but so far I haven't got it to work. Can someone point out what I'm missing?
Below is the code I'm using to get the map name in the XML and save the Weblayout: MapGuideApi.MgInitializeWebTier(classLibraryPublicConstants.constants.configFilePath) Dim userInfo As MgUserInformation = New MgUserInformation(sessionID) Dim siteConnection As MgSiteConnection = New MgSiteConnection() siteConnection.Open(userInfo) Dim resourceService As MgResourceService = siteConnection.CreateService(MgServiceType.ResourceService) Dim featureService As MgFeatureService = siteConnection.CreateService(MgServiceType.FeatureService) Dim queryOptions As MgFeatureQueryOptions = New MgFeatureQueryOptions() Dim map As MgMap = New MgMap(siteConnection) map.Open(mapName) Dim webLayoutResourceIDPath As MgResourceIdentifier = New MgResourceIdentifier("Library://Web_Layouts/" & webLayoutName & ".WebLayout") Dim webLayoutByteReader As MgByteReader = resourceService.GetResourceContent(webLayoutResourceIDPath) Dim webLayoutXML As New XmlDocument webLayoutXML.LoadXml(webLayoutByteReader.ToString) 'new Dim MapNodeList As XmlNodeList = webLayoutXML.GetElementsByTagName("Map") For Each node As XmlElement In MapNodeList Dim VisibleNodeList As XmlNodeList = node.GetElementsByTagName("ResourceId") If VisibleNodeList.Count > 0 Then VisibleNodeList.Item(0).FirstChild.Value = newMapName End If Next Dim MapDefinitionStr As String = webLayoutXML.OuterXml.ToString() 'end new Dim mapNode As XmlNode = webLayoutXML.GetElementsByTagName("Map").Item(0) mapNode.InnerText = newMapName Dim xmlStream As New MemoryStream webLayoutXML.Save(xmlStream) Dim webLayoutDefinition As Byte() = xmlStream.ToArray Dim utf8 As Encoding = Encoding.UTF8 Dim webLayoutDefString As String = New String(utf8.GetChars(webLayoutDefinition)) webLayoutDefinition = New Byte(webLayoutDefString.Length - 1) {} Dim byteCount As Integer = utf8.GetBytes(webLayoutDefString, 1, webLayoutDefString.Length - 1, webLayoutDefinition, 0) Dim byteSource As MgByteSource = New MgByteSource(webLayoutDefinition, webLayoutDefinition.Length) byteSource.SetMimeType(MgMimeType.Xml) Dim tempWebLayoutResID As New MgResourceIdentifier("Session:" & sessionID & "//" & webLayoutName & ".WebLayout") 'resourceService.SetResource(tempWebLayoutResID, byteSource.GetReader(), Nothing) resourceService.SetResource(tempWebLayoutResID, New MgByteReader(MapDefinitionStr, "text/xml"), Nothing) map.Save(resourceService) The dropdown changes the selected map: Dim mgSessionId As String = hdnSession.Value Dim mapName As String = hdnMapName.Value strIFrameSrc = strLayoutTemplateLocation + "?WEBLAYOUT=Library%3a%2f%2fWeb_Layouts%2fMY_BASIC.WebLayout&LOCALE=en&username=Anonymous&password=" Below is the aspx of the page that loads the map: <iframe height="100%" id="iFrameMap" name="iFrameMap" width="100%" src="<%= strIFrameSrc %>" > </iframe> Currently the new map doesn't load, it just reloads the existing map again and when doing so it also loses the weblayout configuration too. (ie. size of mapframe is no longer 100%) Any help on this would be appreciated. thanks. -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Load-different-map-in-weblayout-Basic-viewer-tp6869814p6869814.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