Hi Gordon,
This is part of a code. I have Session and MapName and I can’t read the map
object of a session.
public class UtilMap : IDisposable
private string strSessionMap;
private string strMapDefinition;
private MgSiteConnection siteConnection;
private MgUserInformation userInfo;
private MgFeatureService featureService;
private MgResourceService resourceService;
private MgMap map;
private string mapName;
private string strTempLayerSufix;
/// <summary>
/// Constructor of class to manipulate the RunTime Mapguide Map
/// </summary>
/// <param name="pstrSessionMap">Map Session ID</param>
/// <param name="pstrMapDefinition">Map Library Definition</param>
public UtilMap(string pstrSessionMap, string pstrMapDefinition)
{
try
{
this.strSessionMap = pstrSessionMap;
this.strMapDefinition = pstrMapDefinition;
this.strTempLayerSufix = "-" + strSessionMap;
this.siteConnection = new MgSiteConnection();
this.userInfo = new MgUserInformation(this.strSessionMap);
try
{
this.siteConnection.Open(this.userInfo);
}
catch (Exception ex)
{
throw new Exception("Erro UtilMap SiteConnection Open: " +
ex.Message);
}
this.featureService =
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
this.resourceService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
this.mapName = this.strMapDefinition;
// if mapName is empty, I just want to work with session
repository, no map session operations
if (!string.IsNullOrEmpty(this.mapName))
{
this.map = new MgMap(this.siteConnection);
try
{
this.map.Open(this.resourceService, this.mapName);
}
catch (Exception ex)
{
throw new Exception("Error UtilMap Map Open: " +
ex.Message);
}
}
}
catch (Exception ex)
{
// Cleans internal references, if implemented correctly
if (this.siteConnection != null){this.siteConnection.Dispose();
this.siteConnection = null;}
if (this.userInfo != null){this.userInfo.Dispose(); this.userInfo =
null;}
if (this.featureService != null){this.featureService.Dispose();
this.featureService = null;}
if (this.resourceService != null){this.resourceService.Dispose();
this.resourceService = null;}
if (this.map != null){this.map.Dispose(); this.map = null;}
throw new Exception("Error UtilMap criation: pstrSessionMap = " +
pstrSessionMap + ", pstrMapDefinition = " + pstrMapDefinition + " :: Mensagem :
"+ ex.Message);
}
}
public void SetFusionViewerInitialView(string webLayoutDefinition, double
dblX, double dblY, double dblScale)
{
MgResourceIdentifier resourceID = null;
MgByteReader reader = null;
string strXml = string.Empty;
try
{
// IT DOES NOT WORK
resourceID = this.map.GetMapDefinition();
reader =
this.resourceService.GetResourceContent(resourceID);
strXml = reader.ToString();
// I CAN NOT FIND THE MAP OBJECT
//resourceID = new MgResourceIdentifier("Session:" +
this.strSessionMap + "//" + this.mapName + "." + MgResourceType.MapDefinition);
resourceID = new
MgResourceIdentifier("Session:" + this.strSessionMap + "//" + this.mapName +
this.strTempLayerSufix + "." + MgResourceType.MapDefinition);
reader =
this.resourceService.GetResourceContent(resourceID);
strXml = reader.ToString();
}
catch (Exception ex)
{
throw new
Exception(System.Reflection.MethodInfo.GetCurrentMethod().Name + "::" +
ex.Message);
}
finally
{
if (resourceID != null) { resourceID.Dispose();
resourceID = null; }
if (reader != null) { reader.Dispose(); reader = null; }
}
}
}
Regards,
Liglio Cavalcante
De: Gordon Luckett <[email protected]>
Enviada em: quarta-feira, 3 de junho de 2026 15:26
Para: MapGuide Users Mail List <[email protected]>
Cc: [email protected]
Assunto: Re: [mapguide-users] Modify the map definition and web layout flexible
definition of a session
If you have the Session and MapName you should be able to modify the map
without needing the MgResourceIdenifier.
On Wed, Jun 3, 2026 at 2:06 PM Liglio Cavalcante via mapguide-users
<[email protected] <mailto:[email protected]> > wrote:
Hi,
Is it possible to read and modify the map definition and web layout flexible
definition of a session ?
I tried serveral combinations of map names for the resource ID, with no success.
Example:: resourceID = new MgResourceIdentifier("Session:" + sessionId + "//" +
"Mapa GIS - Fusion" + "." + MgResourceType.MapDefinition);
Regards,
Liglio Cavalcante
_______________________________________________
mapguide-users mailing list
[email protected] <mailto:[email protected]>
https://lists.osgeo.org/mailman/listinfo/mapguide-users
_______________________________________________
mapguide-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapguide-users