Opened 14 years ago

Closed 14 years ago

#1432 closed defect (invalid)

Adding a Layer at Runtime

Reported by: Cristian Owned by:
Priority: high Milestone:
Component: Viewer API Version: 2.2.0
Severity: trivial Keywords: MgMap.Save()
Cc: External ID:

Description

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

Change History (2)

comment:1 by jng, 14 years ago

MgMap.Save() can only be used if the MgMap was instantiated with the MgMap(MgSiteConnection) constructor

comment:2 by tomfukushima, 14 years ago

Resolution: invalid
Status: newclosed

I think that this is a good question for the mapguide-users list. Closing.

Note: See TracTickets for help on using tickets.