[mapguide-users] Help with opening maps from code behind

Ivan Milicevic Ivan.Milicevic at supranet.hr
Mon Dec 10 04:39:21 EST 2007

Thank! That was helpful!


From: mapguide-users-bounces at lists.osgeo.org on behalf of Kenneth, GEOGRAF A/S
Sent: pon 10.12.2007 10:10
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Help with opening maps from code behind

I can't guess what you want to do.
The name of the map that you are trying to open is constructed by the AJAX viewer, and is always identical to the name of the MapDefinition on which it is based.
If you want to read the name, open the WebLayout, look at the resourceID: "Library://Folder/MyMap.MapDefinition".
In the above case, the name will be "MyMap". It will be stored as "Session:xxx//MyMap.Map" where xxx is the session id.

The rename operation is called "MoveResource" but I don't know how it is exposed in the API.
Beware that moving resources will break any references to the resource.

A much easier approach is to save the map under a different name. 
If you save in the session repository, it will be cleaned up on session expiration.

If you want to switch runtime maps, I suggest you try out the Fusion viewer from MGOS 2.0 Beta 1, as it supports that.

Regards, Kenneth, GEOGRAF A/S

Ivan Milicevic skrev: 

	is it possible to change map nae programaticly on runtime? I need to change map name, do something with layers and then render map image. I'm struggling with this for last 20h.
	Please if somebody can help me. The problem is down below at commented line.
	string mgSessionId = Request.QueryString["mgSessionId"].ToString();
	string idK = Page.Request.QueryString["idK"];
	string idZ = Page.Request.QueryString["idZ"];
	string oznakaZdenca;
	string cijeviKabela;
	int i = 0;
	bool showPreviousResults = false;
	MgSiteConnection siteConnection = null;
	MgUserInformation userInfo = new MgUserInformation(mgSessionId);
	siteConnection = new MgSiteConnection();
	MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
	MgFeatureService featureService = siteConnection.CreateService(MgServiceType.FeatureService) as MgFeatureService;
	MgMap map = new MgMap();
	map.Open(resourceService, "1"); //opening map with name "1". I need to change map name here 

	mapguide-users mailing list
	mapguide-users at lists.osgeo.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5113 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapguide-users/attachments/20071210/354fe6c9/attachment.bin

More information about the mapguide-users mailing list