This sample demonstrates applying custom colors to a
FlareClusterer. In the sample XAML, custom colors are applied via
the FlareClusterer's Background, Foreground, and Gradient
properties
Download Sample Application
< UserControl x:Class = " ArcGISWPFSDK.LocalSimpleClusterer "
xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns:x = " http://schemas.microsoft.com/winfx/2006/xaml "
xmlns:esri = " http://schemas.esri.com/arcgis/client/2009 " >
< Grid x:Name = " LayoutRoot " Background = " White " >
< Grid.Resources >
< esri : SimpleMarkerSymbol x:Key = " MediumMarkerSymbol " Color = " #FF00BB00 " Size = " 12 " Style = " Circle " />
< LinearGradientBrush x:Key = " BlueGradient " MappingMode = " RelativeToBoundingBox " >
< GradientStop Color = " #990011FF " Offset = " 0 " />
< GradientStop Color = " #990055FF " Offset = " 0.25 " />
< GradientStop Color = " #990099FF " Offset = " 0.5 " />
< GradientStop Color = " #9900CCFF " Offset = " 0.75 " />
< GradientStop Color = " #9900FFFF " Offset = " 1 " />
</ LinearGradientBrush >
</ Grid.Resources >
< esri : Map x:Name = " MyMap " WrapAround = " True " Extent = " -15000000,2000000,-7000000,8000000 " Background = " #FFE3E3E3 " MinimumResolution = " 2445.98490512499 " >
< esri : ArcGISLocalTiledLayer ID = " myBaseMap " Path = " ..\\Data\\TPKs\\Topographic.tpk " />
< esri : GraphicsLayer ID = " MyGraphicsLayer " >
< esri : GraphicsLayer.Clusterer >
< esri : FlareClusterer
FlareBackground = " Yellow "
FlareForeground = " #99000000 "
MaximumFlareCount = " 5 " Radius = " 15 "
Gradient = " {StaticResource BlueGradient} " />
</ esri : GraphicsLayer.Clusterer >
</ esri : GraphicsLayer >
</ esri : Map >
</ Grid >
</ UserControl >
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Local;
namespace ArcGISWPFSDK
{
public partial class LocalSimpleClusterer : UserControl
{
LocalMapService _mapService;
public LocalSimpleClusterer()
{
InitializeComponent();
LocalMapService.GetServiceAsync("..\\Data\\MPKS\\USCitiesStates.mpk" , (localMapService) =>
{
_mapService = localMapService;
QueryTask queryTask = new QueryTask();
queryTask.Url = _mapService.UrlMapService + "/0" ;
queryTask.ExecuteCompleted += queryTask_ExecuteCompleted;
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
query.OutSpatialReference = MyMap.SpatialReference;
query.ReturnGeometry = true ;
query.Where = "1=1" ;
queryTask.ExecuteAsync(query);
});
}
void queryTask_ExecuteCompleted(object sender, QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;
if (featureSet == null || featureSet.Features.Count < 1)
{
MessageBox.Show("No features retured from query" );
return ;
}
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer" ] as GraphicsLayer;
foreach (Graphic graphic in featureSet.Features)
{
graphic.Symbol = LayoutRoot.Resources["MediumMarkerSymbol" ] as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol;
graphicsLayer.Graphics.Add(graphic);
}
}
}
}
Imports System.Windows
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Tasks
Imports ESRI.ArcGIS.Client.Local
Namespace ArcGISWPFSDK
Partial Public Class LocalSimpleClusterer
Inherits UserControl
Private _mapService As LocalMapService
Public Sub New ()
InitializeComponent()
LocalMapService.GetServiceAsync("..\Data\MPKS\USCitiesStates.mpk" , Function (localMapService__1)
_mapService = localMapService__1
Dim queryTask As New QueryTask()
queryTask.Url = _mapService.UrlMapService & "/0"
AddHandler queryTask.ExecuteCompleted, AddressOf queryTask_ExecuteCompleted
Dim query As Query = New ESRI.ArcGIS.Client.Tasks.Query()
query.OutSpatialReference = MyMap.SpatialReference
query.ReturnGeometry = True
query.Where = "1=1"
queryTask.ExecuteAsync(query)
End Function )
End Sub
Private Sub queryTask_ExecuteCompleted(sender As Object , args As QueryEventArgs)
Dim featureSet As FeatureSet = args.FeatureSet
If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
MessageBox.Show("No features retured from query" )
Return
End If
Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer" ), GraphicsLayer)
For Each graphic As Graphic In featureSet.Features
graphic.Symbol = TryCast(LayoutRoot.Resources("MediumMarkerSymbol" ), ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol)
graphicsLayer.Graphics.Add(graphic)
Next
End Sub
End Class
End Namespace
5/16/2014