When the MapDefinition is turned into a runtime Map, it copies properties from the layerdefinition. This means that you will see no changes, even if you choose to modify the LayerDefinition.

You must modify the layer copy in the runtime map.
Fortunately, that is actually easier than what you are doing now:

MgMap map = new MgMap();
map.Open("map", srv);

map.Layers("layername").Filter = "Column = 5";
map.Save();

Regards, Kenneth, GEOGRAF A/S



Maksim Sestic skrev:
I think I'm having problems with changing existing dynamic layer's Filter
property (the one that filters data from FeatureSource) using .NET. Here's
the approach that doesn't report any error, but when I refresh the map there
are no changes to the layer - new filter doesn't get applied.

Dim layer As MgLayer = ...getting a MgLayer object...
Dim document As New XmlDocument
document.PreserveWhitespace = True
Dim byteReader As MgByteReader =
resources.Service.GetResourceContent(layer.LayerDefinition)
document.LoadXml(byteReader.ToString)

Allright, it's all in XmlDocument now and then I do some parsing to change
the Filter element. When I save the definition to XML file (just for
testing) everything's OK, structure and data is preserved and Filter element
is set to some new value.

' Saving XmlDocument to memory stream
Dim stream As MemoryStream = New System.IO.MemoryStream()
document.Save(stream)

' Converting stream to byte array Dim byteArray() As Byte = stream.ToArray

' Converting byte array to String (BOM included, otherwise SetResource
raises an error while parsing XML)
Dim outerXml As String = System.Text.Encoding.UTF8.GetString(byteArray, 0,
byteArray.Length - 1)

' Converting String to byte array with UTF-8 encoding byteArray = System.Text.Encoding.UTF8.GetBytes(outerXml)

' Creating MgByteSource out of byte array, setting appropriate MimeType
Dim byteSource As MgByteSource = New MgByteSource(byteArray,
byteArray.Length)
byteSource.SetMimeType(MgMimeType.Xml)

' Getting MgResourceIdentifier corresponding to current SessionId and
existing Layer name
Dim resourceId As New
MgResourceIdentifier(String.Format("Session:{0}//{1}.LayerDefinition",
sessionId, layerName))

' Setting a resource (without Header) using MgResourceIdentifier and byte
source
resources.Service.SetResource(resourceId, byteSource.GetReader, Nothing)

' I don't know if this is necessary, but still...
layer.ForceRefresh()


Now, when I call parent.parent.Refresh() on the client side nothing happens.
What am I doing wrong here?

Regards,
Maksim Sestic




_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to