Changes between Initial Version and Version 1 of maestro/MaestroAPI/samples/ModifyLayerFilter


Ignore:
Timestamp:
Dec 8, 2008, 8:41:28 AM (15 years ago)
Author:
ksgeograf
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • maestro/MaestroAPI/samples/ModifyLayerFilter

    v1 v1  
     1== Utilizing !RuntimeMap via Maestro API ==
     2This page describes how to use the MaestroAPI from the [wiki:maestro MapGuide Maestro] project in your own application.
     3
     4This example shows how to modify the filter of a layer, so it displays another subset of the features.
     5The filter is changed only in the current session, meaning that other users won't be affected.
     6The code should be placed in an aspx page, otherwise the RegisterStartupScript call won't work.
     7
     8This example uses the http version, so no MapGuide binaries are required.
     9Read about [wiki:maestro/MaestroAPI/basics the difference between LocalNativeConnection and HttpServerConnection here]
     10
     11(VB.NET)
     12{{{
     13Imports OSGeo.MapGuide.MaestroAPI
     14...
     15
     16'Read setup from querystring or form
     17Dim sessionID As String = Request.Params("SESSIONID")
     18Dim mapdefinition As String = Request.Params("MAPDEFINITION")
     19Dim layername As String = Request.Params("LAYERNAME")
     20Dim newFilter As String = Request.Params("NEWFILTER")
     21
     22'Replace "myserver" with the server name, or use "localhost"
     23Dim host As New Uri("http://myserver/mapguide/mapagent/mapagent.fcgi")
     24Dim conn as ServerConnectionI = New HttpServerConnection(host, sessionID, "en", true)
     25
     26'Use the same naming system as the viewer, when reading the runtime map ID
     27Dim mapName as String = new ResourceIdentifier(mapdefinition).Name
     28Dim rtMapId as String = new ResourceIdentifier(mapName, ResourceTypes.RuntimeMap, conn.SessionID)
     29
     30'Load the runtime map
     31Dim rtMap as RuntimeClasses.RuntimeMap = conn.GetRuntimeMap(rtMapId)
     32Dim rtLayer as RuntimeClasses.RuntimeMapLayer = rtMap.Layers(layername)
     33
     34'Get the current layer and assing the filter
     35Dim layerDefinition as LayerDefinition = conn.GetLayerDefinition(rtLayer.ResourceId)
     36Dim vectorLayerDefinition as VectorLayerDefinitionType = layerDefinition.Item
     37vectorLayerDefinition.Filter = newFilter
     38
     39'Save a copy of the layer, temporary, and random name
     40rtLayer.ResourceID = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefinition, conn.SessionID)
     41conn.SaveResourceAs(layerDefinition, rtLayer)
     42
     43'Save the runtime map, pointing to the updated layerdefinition
     44conn.SaveRuntimeMap(rtMapId, rtMap)
     45
     46'Tell the client to refresh
     47RegisterStartupScript("key", "<script>GetMapFrame().Refresh();</script>")
     48
     49}}}