[mapguide-users] Edit Layer

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Mon Dec 8 11:43:17 EST 2008


You need to call the aspx page with the session id, either as a 
querystring or as a post.

'Read setup from querystring or form
Dim sessionID As String = Request.Params("SESSIONID")
Dim mapdefinition As String = Request.Params("MAPDEFINITION")
Dim layername As String = Request.Params("LAYERNAME")
Dim newFilter As String = Request.Params("NEWFILTER")

'Replace "myserver" with the server name, or use "localhost"
Dim host As New Uri("http://myserver/mapguide/mapagent/mapagent.fcgi")
Dim conn as ServerConnectionI = New HttpServerConnection(host, sessionID, "en", true)

'Use the same naming system as the viewer, when reading the runtime map ID
Dim mapName as String = new ResourceIdentifier(mapdefinition).Name
Dim rtMapId as String = new ResourceIdentifier(mapName, ResourceTypes.RuntimeMap, conn.SessionID)

'Load the runtime map
Dim rtMap as RuntimeClasses.RuntimeMap = conn.GetRuntimeMap(rtMapId)
Dim rtLayer as RuntimeClasses.RuntimeMapLayer = rtMap.Layers(layername)

'Get the current layer and assing the filter
Dim layerDefinition as LayerDefinition = conn.GetLayerDefinition(rtLayer.ResourceId)
Dim vectorLayerDefinition as VectorLayerDefinitionType = layerDefinition.Item
vectorLayerDefinition.Filter = newFilter

'Save a copy of the layer, temporary, and random name
rtLayer.ResourceID = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefinition, conn.SessionID)
conn.SaveResourceAs(layerDefinition, rtLayer)

'Save the runtime map, pointing to the updated layerdefinition
conn.SaveRuntimeMap(rtMapId, rtMap)

'Tell the client to refresh
RegisterStartupScript("key", "<script>GetMapFrame().Refresh();</script>")

Regards, Kenneth Skovhede, GEOGRAF A/S



padmini godavarthi skrev:
> Hi 
> iam using Mapguide opensource 2.0(with .net 2.0 +IIS 5.1)
>
> Hi, We want modify dynamically a layer; for exemple, modify the filter of a
> layer  when the map is loaded;Is it possible ? What is the method : using an
> API ?  
>
>
> can u give me the sample code in .net so that it will be very helpful to me
>
> Regards,
> Padmini.
>   


More information about the mapguide-users mailing list