A renderer that can display features in a graphics layer with multiple symbol types.
Object Model
Syntax
Type Parameters
- T
- The type of the data to be used for assigning features to renderer groups (values).
Example
This example creates a new ValueMapRenderer, adds two symbol classes to it, and then uses the renderer for a new graphics layer added to the map. To run this sample on a page:
- Create a new ASPX page.
- Add MapResourceManager, Map and Toc controls and set required properties (Map's MapResourceManager, Toc's Map properties).
- Add a resource item to the MapResourceManager with a map service, then add a second resource item with type GraphicsLayer with a name of "graphicsLayer0". Move the graphics resource to the top of the list of resources.
- Add the sample code into the Page_PreRender event handler method (create this method if necessary).
- Change the point x and y locations if necessary to fit within your map service's extent.
- Run the sample page. Two point symbols will be added to the map display.
C# | Copy Code |
---|
// Create new ValueMapRenderer
ValueMapRenderer<int> vMapRend = new ValueMapRenderer<int>();
// Column in data table with data for rendering
vMapRend.ValueColumnName = "Population";
SimpleMarkerSymbol sms;
// Create a ValueRange for the first class
ValueRange<int> valRange;
valRange = new ValueRange<int>();
valRange.MinValue = 0;
valRange.MaxValue = 100;
valRange.Bounds = RangeBounds.Lower;
sms = new SimpleMarkerSymbol
(System.Drawing.Color.Blue, 12);
valRange.SymbolLabel = "Low";
valRange.Symbol = sms;
vMapRend.Values.Add(valRange);
// Create a ValueRange for the second class
valRange = new ValueRange<int>();
valRange.MinValue = 100;
valRange.MaxValue = 1000;
valRange.Bounds = RangeBounds.Upper;
sms = new SimpleMarkerSymbol(
System.Drawing.Color.Red, 15);
valRange.Symbol = sms;
valRange.SymbolLabel = "High";
vMapRend.Values.Add(valRange);
// Create new graphics layer with two points
FeatureGraphicsLayer grLayer = new FeatureGraphicsLayer(
"MyGraphicsLayer",
ESRI.ArcGIS.ADF.Web.FeatureType.Point,
vMapRend);
grLayer.GeometryColumnName = "geom";
grLayer.Columns.Add("Population", typeof(int));
DataRow graphicFeature;
// First point
graphicFeature = grLayer.NewRow();
graphicFeature["Population"] = 52;
graphicFeature["geom"] =
new ESRI.ArcGIS.ADF.Web.Geometry.Point(-92.0, 45.0);
grLayer.Rows.Add(graphicFeature);
// Second point
graphicFeature = grLayer.NewRow();
graphicFeature["Population"] = 389;
graphicFeature["geom"] =
new ESRI.ArcGIS.ADF.Web.Geometry.Point(36.0, -12.0);
grLayer.Rows.Add(graphicFeature);
// Get the graphics resource from the Map/MapResourceManager
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality graphicsFunct =
Map1.GetFunctionality("graphicsLayer0")
as ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality;
if (graphicsFunct != null)
{
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource mapResource =
graphicsFunct.Resource as
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource;
// Add the graphics layer to the map
mapResource.Graphics.Tables.Add(grLayer);
} |
Visual Basic | Copy Code |
---|
' Create new ValueMapRenderer
Dim vMapRend As New ValueMapRenderer(Of Integer)()
' Column in data table with data for rendering
vMapRend.ValueColumnName = "Population"
Dim sms As SimpleMarkerSymbol
' Create a ValueRange for the first class
Dim valRange As New ValueRange(Of Integer)()
valRange.MinValue = 0
valRange.MaxValue = 100
valRange.Bounds = RangeBounds.Lower
sms = New SimpleMarkerSymbol(System.Drawing.Color.Blue, 12)
valRange.SymbolLabel = "Low"
valRange.Symbol = sms
vMapRend.Values.Add(valRange)
' Create a ValueRange for the second class
valRange = New ValueRange(Of Integer)()
valRange.MinValue = 100
valRange.MaxValue = 1000
valRange.Bounds = RangeBounds.Upper
sms = New SimpleMarkerSymbol(System.Drawing.Color.Red, 15)
valRange.Symbol = sms
valRange.SymbolLabel = "High"
vMapRend.Values.Add(valRange)
' Create new graphics layer with two points
FeatureGraphicsLayer grLayer = New FeatureGraphicsLayer( _
"MyGraphicsLayer", _
ESRI.ArcGIS.ADF.Web.FeatureType.Point, _
vMapRend)
grLayer.GeomeTryColumnName = "geom"
grLayer.Columns.Add("Population", Type.GetType(Integer))
Dim graphicFeature As DataRow
' First point
graphicFeature = grLayer.NewRow()
graphicFeature("Population") = 52
graphicFeature("geom") = _
New ESRI.ArcGIS.ADF.Web.GeomeTry.Point(-92.0, 45.0)
grLayer.Rows.Add(graphicFeature)
' Second point
graphicFeature = grLayer.NewRow()
graphicFeature("Population") = 389
graphicFeature("geom") = _
New ESRI.ArcGIS.ADF.Web.GeomeTry.Point(36.0, -12.0)
grLayer.Rows.Add(graphicFeature)
' Get the graphics resource from the Map/MapResourceManager
Dim graphicsFunct As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality
graphicsFunct = CType(Map1.GetFunctionality("graphicsLayer0"), _
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)
If graphicsFunct IsNot Nothing Then
Dim mapResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource
mapResource = CType(graphicsFunct.Resource, _
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)
' Add the graphics layer to the map
mapResource.Graphics.Tables.Add(grLayer)
End If |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also