Class MapSelection
Represents a map selection
Inheritance
Implements
Inherited Members
Namespace: OSGeo.MapGuide.MaestroAPI.Mapping
Assembly: OSGeo.MapGuide.MaestroAPI.dll
Syntax
public class MapSelection : IBinarySerializable, IList<MapSelection.LayerSelection>, ICollection<MapSelection.LayerSelection>, IEnumerable<MapSelection.LayerSelection>, IEnumerable
Examples
This sample shows how to list selected features in ASP.net. The sample expects 3 parameters:
- The session ID (SESSION)
- The runtime map name (MAPNAME)
- The selection XML (SELECTION)
string agent = "http://localhost/mapguide/mapagent/mapagent.fcgi";
IServerConnection conn = ConnectionProviderRegistry.CreateConnection(
"Maestro.Http",
"Url", agent,
"SessionId", Request.Params["SESSION"]);
IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
string rtMapId = "Session:" + conn.SessionID + "//" + Request.Params["MAPNAME"] + ".Map";
RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
string xml = Request.Params["SELECTION"];
//The map selection contains one or more layer selections
//each containing a one or more sets of identity property values
//(because a feature may have multiple identity properties)
MapSelection selection = new MapSelection(rtMap, System.Web.HttpUtility.UrlDecode(xml));
if (selection.Count > 0)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < selection.Count; i++)
{
MapSelection.LayerSelection layerSel = selection[i];
sb.Append("<p>Layer: " + layerSel.Layer.Name + " (" + layerSel.Count + " selected item)");
sb.Append("<table>");
for (int j = 0; j < layerSel.Count; j++)
{
sb.Append("<tr>");
object[] values = layerSel[j];
for (int k = 0; k < values.Length; k++)
{
sb.Append("<td>");
sb.Append(values[k].ToString());
sb.Append("</td>");
}
sb.AppendFormat("<td><a href='FeatureInfo.aspx?MAPNAME={0}&SESSION={1}&LAYERID={2}&ID={3}'>More Info</a></td>",
rtMap.Name,
conn.SessionID,
layerSel.Layer.ObjectId,
System.Web.HttpUtility.UrlEncode(layerSel.EncodeIDString(values)));
sb.Append("</tr>");
}
sb.Append("</table>");
Response.WriteLine("<p>Showing IDs of selected features</p>");
Response.WriteLine(sb.ToString());
}
}
else
{
Response.WriteLine("Nothing selected. Select some features first then run this sample again.");
}
Constructors
| Improve this Doc View SourceMapSelection(RuntimeMap)
Constructor
Declaration
public MapSelection(RuntimeMap map)
Parameters
Type | Name | Description |
---|---|---|
Runtime |
map |
MapSelection(RuntimeMap, String)
Constructor
Declaration
public MapSelection(RuntimeMap map, string xml)
Parameters
Type | Name | Description |
---|---|---|
Runtime |
map | |
System. |
xml |
Properties
| Improve this Doc View SourceCount
Gets the number of layers in this selection
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System. |
IsReadOnly
Gets whether this is read only
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System. |
Item[RuntimeMapLayer]
Gets the selection layer at a given index
Declaration
public MapSelection.LayerSelection this[RuntimeMapLayer index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Runtime |
index | The index to get or set the item for |
Property Value
Type | Description |
---|---|
Map |
The item at the given index |
Item[Int32]
Gets or sets the selection layer at a given index
Declaration
public MapSelection.LayerSelection this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System. |
index | The index to get or set the item for |
Property Value
Type | Description |
---|---|
Map |
The item at the given index |
Methods
| Improve this Doc View SourceAdd(MapSelection.LayerSelection)
Adds the specified layer selection
Declaration
public void Add(MapSelection.LayerSelection item)
Parameters
Type | Name | Description |
---|---|---|
Map |
item |
Add(RuntimeMapLayer)
Adds the specified layer
Declaration
public void Add(RuntimeMapLayer layer)
Parameters
Type | Name | Description |
---|---|---|
Runtime |
layer |
Clear()
Clears this selction
Declaration
public void Clear()
Contains(MapSelection.LayerSelection)
Gets whether this selection contains the specified layer selection
Declaration
public bool Contains(MapSelection.LayerSelection item)
Parameters
Type | Name | Description |
---|---|---|
Map |
item |
Returns
Type | Description |
---|---|
System. |
Contains(RuntimeMapLayer)
Gets whether this selection contains the specified layer
Declaration
public bool Contains(RuntimeMapLayer item)
Parameters
Type | Name | Description |
---|---|---|
Runtime |
item |
Returns
Type | Description |
---|---|
System. |
CopyTo(MapSelection.LayerSelection[], Int32)
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.
Declaration
public void CopyTo(MapSelection.LayerSelection[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
Map |
array | The one-dimensional System. |
System. |
arrayIndex | The zero-based index in |
Exceptions
Type | Condition |
---|---|
System. |
|
System. |
|
System. |
|
Deserialize(MgBinaryDeserializer)
Deserializes this object using the specified deserializer.
Declaration
public void Deserialize(MgBinaryDeserializer d)
Parameters
Type | Name | Description |
---|---|---|
Mg |
d | The deserializer. |
GetEnumerator()
Gets the layer selection enumerator
Declaration
public IEnumerator<MapSelection.LayerSelection> GetEnumerator()
Returns
Type | Description |
---|---|
System. |
IndexOf(MapSelection.LayerSelection)
Returns the index of the given layer
Declaration
public int IndexOf(MapSelection.LayerSelection item)
Parameters
Type | Name | Description |
---|---|---|
Map |
item | The layer to look for |
Returns
Type | Description |
---|---|
System. |
The index of the layer, or -1 if the layer is not in the collection |
IndexOf(RuntimeMapLayer)
Returns the index of the given layer
Declaration
public int IndexOf(RuntimeMapLayer layer)
Parameters
Type | Name | Description |
---|---|---|
Runtime |
layer | The layer. |
Returns
Type | Description |
---|---|
System. |
The index of the layer, or -1 if the layer is not in the collection |
Insert(Int32, MapSelection.LayerSelection)
Inserts a selection layer into the collection
Declaration
public void Insert(int index, MapSelection.LayerSelection item)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | The index to place the item at |
Map |
item | The item to insert |
Insert(Int32, RuntimeMapLayer)
Inserts a selection layer into the collection
Declaration
public void Insert(int index, RuntimeMapLayer layer)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | The index to place the item at |
Runtime |
layer | The layer. |
LoadXml(String)
Initialize this selection from the specified xml string
Declaration
public void LoadXml(string xml)
Parameters
Type | Name | Description |
---|---|---|
System. |
xml |
Remove(MapSelection.LayerSelection)
Removes the specified layer selection
Declaration
public bool Remove(MapSelection.LayerSelection item)
Parameters
Type | Name | Description |
---|---|---|
Map |
item |
Returns
Type | Description |
---|---|
System. |
RemoveAt(Int32)
Removes the item at the given index
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | The index to remove the item at |
Serialize(MgBinarySerializer)
Serializes this instance using the specified serializer.
Declaration
public void Serialize(MgBinarySerializer s)
Parameters
Type | Name | Description |
---|---|---|
Mg |
s | The serializer. |
ToXml()
Returns an xml document that represents the current map selection
Declaration
public string ToXml()
Returns
Type | Description |
---|---|
System. |
An xml document that represents the current map selection |
UpdateFrom(FeatureSet)
Updates this selection from the given input selection set payload
Declaration
public void UpdateFrom(FeatureSet featureSet)
Parameters
Type | Name | Description |
---|---|---|
Feature |
featureSet |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System. |