You cannot use the SessionID directly to access resources.
It must be used to build an URI like this:

"Session:<sessionid>//Map1.Map"
where "<sessionid>" is the value you get from GetSessionId().

This is mentioned on page 19 in the manual.

Regards, Kenneth, GEOGRAF A/S



dorra2007 skrev:
I used this function to get the session ID :
document.myform.session.value=parent.parent.mapFrame.GetSessionId();

But I have this error:

The session ID is invalid because the session separator character was not
found

Have you an idea about the "session separator"?


Regards.


Kenneth, GEOGRAF A/S wrote:
I assume that you do know that the code below is in Java/JSP and not javascript.

The resourceService is created from the site, with CreateService.

I just tried to find the example in the HTML version of the manual, with no luck, try the PDF version instead:
http://mapguide.osgeo.org/files/mapguide/docs/MgOpenSourceDevGuide.pdf

Page 36:

MgInitializeWebTier ($webconfigFilePath);
$userInfo = new MgUserInformation($mgSessionId);
$siteConnection = new MgSiteConnection();
$siteConnection->Open($userInfo);
$resourceService =
  $siteConnection->CreateService(MgServiceType::ResourceService);
$map = new MgMap();
$map->Open($resourceService, $mgMapName);
$layers = $map->GetLayers();
$roadLayer = $layers->GetItem('Roads');
$roadLabel = $roadLayer->GetLegendLabel();
if ($roadLabel == 'Roads')
$newLabel = 'Streets';
else
$newLabel = 'Roads';
$roadLayer->SetLegendLabel($newLabel);
// You must save the updated map or the
// changes will not be applied
// Also be sure to refresh the map on page load.
$map->Save($resourceService);

On-top-of-my-head translation to jsp:


MgInitializeWebTier (webconfigFilePath);
MgUserInformation userInfo = new MgUserInformation(mgSessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resourceService =
  siteConnection.CreateService(MgServiceType::ResourceService);
MgMap map = new MgMap();
map.Open(resourceService, mgMapName);
MgLayerCollection layers = map.GetLayers();
MgLayer roadLayer = layers.GetItem('Roads');
roadLabel = roadLayer.GetLegendLabel();

String newLabel;
if (roadLabel == "Roads")
newLabel = "Streets";
else
newLabel = "Roads";
roadLayer.SetLegendLabel(newLabel);
// You must save the updated map or the
// changes will not be applied
// Also be sure to refresh the map on page load.
map.Save(resourceService);

Regards, Kenneth, GEOGRAF A/S



dorra2007 skrev:
Hi all;
I have read several posts about the setvisible function, but I have still
errors in my code  (I am using javascript/jsp).

Can someone give me a comprhensive code in javascript, wich show how i
can
use the SetVisible method?
PS: My featuresource is a postgis database.

here is the code i used:

map=new MgMap();
map.open(resourceService,map_name);
layer=map.GetLayers().GetItem(layer_name);
layer.SetVisible(true);
map.save(resourceService);

the resourceService is not defined. In fact, what does it refers to?And
how
can I define it?Should I create a map object?..

Many question, can someone help me?

Thank you in advance.
_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users



_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to