[mapguide-users] map.Save() raise MgNotImplementedException,programmatically add layer to a map
Champin
champingfor at 163.com
Mon Sep 24 13:34:49 EDT 2007
programmatically add layer to a map, map.Save() raise
MgNotImplementedException
I am trying to create a temperory layer and adding it the map.
map.Save(resourceService) raise the MgNotImplementedException.
what am doing is:
1. Create a map object and open the Map
MgMap map = new MgMap();
map.Open(resService, "MyMap");
2.Create the feature source
create a MgClassDefinition and populate some properties.
.......
create a schema
MgFeatureSchema schema = new MgFeatureSchema("Schema", "the line
schema");
schema.GetClasses().Add(classDef);
MgCreateSdfParams sdfParams = new MgCreateSdfParams("LatLong", srs,
schema);
create the feature source
featureService.CreateFeatureSource(featureSourceId, sdfParams);
2. Create a layerDefinition resource content by loading a layerDefinition
XML and modifying some
.....
resourceService.SetResource(layerId,layerResourceContent,null);
//create the MgLayerBase object
MgLayerBase layer = new MgLayerBase(layerId,resourceService);
3. Set the property of the layer and add it to the Map
layer.SetVisible(true);
........
map.GetLayers().Insert(0,layer);
4. save the map in the session repository.
map.Save(resourceService); ******* // raise
MgNotImplementedException
when the code run into the map.Save(), the MgNotImplementedException raised.
Can you point me what am I missing or something wrong?
By the Way, the code runs quite well on the platform MapGuide
Enterprise(MGOS 1.1)
My MGOS is version 1.2.
and the following code will goes well on MGOS 1.2 on my machine
//////Change the layers visibility programmatically
string sessionId = Request["session"].ToString();
UtilityClass utility = new UtilityClass();
utility.ConnectToServer(sessionId);
//MgFeatureService featureService =
utility.GetSiteConnection().CreateService(MgServiceType.FeatureService) as
MgFeatureService;
MgResourceService resourceService =
utility.GetSiteConnection().CreateService(MgServiceType.ResourceService) as
MgResourceService;
MgMap map = new MgMap();
map.Open(resourceService, "MyMap");
MgLayerBase shipLayer = utility.GetLayerByName(map, "Point");
shipLayer.SetVisible(!shipLayer.GetVisible());
map.Save(resourceService); // no exception raised.
everything goes well. Confused!~~
Enviroment :
VS2005 + MGOS 1.2
--
View this message in context: http://www.nabble.com/map.Save%28%29-raise-MgNotImplementedException%EF%BC%8Cprogrammatically-add-layer-to-a-map-tf4510561s16610.html#a12864473
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list