[mapguide-users] Add Mapguide layer to OpenLayers
Greg
gbneff at cid.utah.gov
Wed Sep 28 13:56:38 EDT 2011
I am looking for a little direction regarding OpenLayers and Mapguide. In
the OpenLayers examples for adding a mapguide layer it shows how to add a
layer like this:
The MapGuide layer can also be created using mapname and session as follows
provided there
is some wrapper code to obtain a valid session id and mapname */
/*
var params = {
mapname: 'Sheboygan49ad9e20e7171',
session:
'7405c17a-0000-1000-8000-0017a4e6ff5d_en_7F0000010AFC0AFB0AFA'
What I am unclear about is the "wrapper code". I am using .net and can
create a mapguide session and get the session but have been unsuccessful at
getting a map name as shown above.
This is what I have tried:
String realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
realPath = realPath.Replace(@"Cid_Map\", "");
String configPath = realPath + "webconfig.ini";
MapGuideApi.MgInitializeWebTier(configPath);
MgUserInformation userinfo = new
OSGeo.MapGuide.MgUserInformation(defaultUser, defaultPassword);
MgSite site = new MgSite();
site.Open(userinfo);
sessionId = site.CreateSession();
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgMap map = new MgMap();
map.Open(resService, "Cid_Map");
mapName = map.GetName().ToString();
I get an error "resource not found" at this line: map.Open(resService,
"Cid_Map")
I am not sure this will give me what I am looking for even if I can get it
to work. Maybe there is an easier way.
Thanks,
Greg
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Add-Mapguide-layer-to-OpenLayers-tp6841213p6841213.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list