[mapguide-users] hide layer on box checked

dorra2007 dorrdor at yahoo.fr
Thu Oct 25 06:36:04 EDT 2007


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 at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://www.nabble.com/hide-layer-on-box-checked-tf4678398s16610.html#a13404034
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list