[mapguide-trac] #1432: Adding a Layer at Runtime

MapGuide Open Source trac_mapguide at osgeo.org
Thu Sep 9 09:37:44 EDT 2010


#1432: Adding a Layer at Runtime
--------------------------+-------------------------------------------------
   Reporter:  Cristian    |       Owner:              
       Type:  defect      |      Status:  new         
   Priority:  high        |   Milestone:              
  Component:  Viewer API  |     Version:  2.2.0       
   Severity:  trivial     |    Keywords:  MgMap.Save()
External_id:              |  
--------------------------+-------------------------------------------------
 I'm a new user of MapGuide.
 I need to change the layers map at runtime.
 When i try to change the visibility layer it works, but when I try to add
 a new layer on the map, the method MgMap.Save() throws NotImplemented
 exception.

 I have two website application developed in ASP.NET under VS 2008.
 One of this is a generic website who allows to browse the resource and the
 second receive the request by first application and send this at MapGuide.

 I can create a valid session with the MG server, I can browse all folder e
 show all resource on the server, but when I add a new layer receive an
 Exception.

 I'm using MapGuide OsGeo 2.2 beta version, but I've the same problem with
 MGOsGeo 2.1.

 This is a part of function who adds the layer.


 {{{
         resId = new MgResourceIdentifier("Session:" + session + "//" +
 layername);
         resService.SetResource(resId, byteSource.GetReader(), null);

         MgLayerBase newLayer = new MgLayerBase(resId, resService);
         MgLayerGroup layerG = new MgLayerGroup("GroupTemp");

         layerG.SetVisible(true);
         layerG.SetDisplayInLegend(true);

         newLayer.SetName(layername + "_TMP");
         newLayer.SetVisible(true);
         newLayer.SetSelectable(false);
         newLayer.SetLegendLabel(layername + "_TMP");
         newLayer.ForceRefresh();

         MgMap mgMap = new MgMap();
         mgMap.Open(resService,
 mapResource.Substring(mapResource.LastIndexOf('/') + 1).Split('.')[0]);
         mgMap.GetLayerGroups().Add(layerG);
         newLayer.SetGroup(layerG);
         mgMap.GetLayers().Insert(0, newLayer);
         mgMap.Save();
 }}}

 I see the resource on the session with MapAgent, so I think that it was
 created.
 I read many example about this and all are doing what I'm doing.
 Where I wrong? It's my problem or it's a problem of MG?

 Regards
 Cristian

-- 
Ticket URL: <http://trac.osgeo.org/mapguide/ticket/1432>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list