Skip to content

Commit

Permalink
Update to replace Earthquakes layer with USA cities mapserver.
Browse files Browse the repository at this point in the history
  • Loading branch information
katydalton committed Apr 27, 2015
1 parent 0d88450 commit b602163
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 314 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
<UserControl x:Class="ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.ClassBreaksRendererSample"
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/runtime/2013">
<Grid x:Name="layoutGrid">
<Grid.Resources>
<esri:SimpleMarkerSymbol x:Key="mag2to3" Color="#FF0A57FC" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="mag3to4" Color="#FF1CA2A3" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="mag4to5" Color="#FF60AD12" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="mag5to6" Color="#FFFFFE0A" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="mag6to7" Color="#FFFDA208" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="mag7to8" Color="#FFFB5107" Size="12" Style="Triangle" />
</Grid.Resources>
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/runtime/2013">
<Grid x:Name="layoutGrid">
<Grid.Resources>
<esri:SimpleMarkerSymbol x:Key="pop0to50K" Color="#FF0A57FC" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="pop50Kto100K" Color="#FF1CA2A3" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="pop100Kto250K" Color="#FF60AD12" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="pop250Kto500K" Color="#FFFFFE0A" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="pop500Kto1000K" Color="#FFFDA208" Size="12" Style="Triangle" />
<esri:SimpleMarkerSymbol x:Key="pop1000K" Color="#FFFB5107" Size="12" Style="Triangle" />
</Grid.Resources>

<esri:MapView x:Name="MyMapView" WrapAround="True">
<esri:Map>
<esri:ArcGISTiledMapServiceLayer
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
</esri:Map>
<esri:MapView x:Name="MyMapView" WrapAround="True">
<esri:Map>
<esri:Map.InitialViewpoint>
<esri:ViewpointExtent XMin="-15053000" YMin="2749000" XMax="-6540000" YMax="6590000" />
</esri:Map.InitialViewpoint>
<esri:ArcGISTiledMapServiceLayer
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
</esri:Map>
<esri:MapView.GraphicsOverlays>
<esri:GraphicsOverlay ID="earthquakes">
<esri:GraphicsOverlay ID="cities">
<esri:GraphicsOverlay.Renderer>
<esri:ClassBreaksRenderer Field="magnitude" >
<esri:ClassBreaksRenderer Field="pop2000" >
<esri:ClassBreaksRenderer.Infos>
<esri:ClassBreakInfo Minimum="2" Maximum="3" Symbol="{StaticResource mag2to3}" />
<esri:ClassBreakInfo Minimum="3" Maximum="4" Symbol="{StaticResource mag3to4}" />
<esri:ClassBreakInfo Minimum="4" Maximum="5" Symbol="{StaticResource mag4to5}" />
<esri:ClassBreakInfo Minimum="5" Maximum="6" Symbol="{StaticResource mag5to6}" />
<esri:ClassBreakInfo Minimum="6" Maximum="7" Symbol="{StaticResource mag6to7}" />
<esri:ClassBreakInfo Minimum="7" Maximum="8" Symbol="{StaticResource mag7to8}" />
<esri:ClassBreakInfo Minimum="0" Maximum="50000" Symbol="{StaticResource pop0to50K}" />
<esri:ClassBreakInfo Minimum="500000" Maximum="100000" Symbol="{StaticResource pop50Kto100K}" />
<esri:ClassBreakInfo Minimum="100000" Maximum="250000" Symbol="{StaticResource pop100Kto250K}" />
<esri:ClassBreakInfo Minimum="250000" Maximum="500000" Symbol="{StaticResource pop250Kto500K}" />
<esri:ClassBreakInfo Minimum="500000" Maximum="1000000" Symbol="{StaticResource pop500Kto1000K}" />
<esri:ClassBreakInfo Minimum="1000000" Maximum="5000000" Symbol="{StaticResource pop1000K}" />
</esri:ClassBreaksRenderer.Infos>
</esri:ClassBreaksRenderer>
</esri:GraphicsOverlay.Renderer>
Expand All @@ -36,16 +39,16 @@
</esri:MapView>

<Border Background="White" BorderBrush="Black" BorderThickness="1" Margin="30" Padding="20"
HorizontalAlignment="Right" VerticalAlignment="Top">
HorizontalAlignment="Right" VerticalAlignment="Top">
<Border.Effect>
<DropShadowEffect />
</Border.Effect>
<StackPanel>
<TextBlock Text="Earthquake points are rendered using the renderer of the graphics layer. The 'Change Renderer' button will change the renderer to a new ClassBreaksRenderer and redraw the map."
FontSize="14" Width="400" TextAlignment="Left" TextWrapping="Wrap" />
<Button Content="Change Renderer" HorizontalAlignment="Center" Margin="12,12,12,0"
Click="ChangeRendererButton_Click"/>
</StackPanel>
</Border>
</Grid>
<TextBlock Text="USA cities are rendered using the renderer of the graphics layer. The 'Change Renderer' button will change the renderer to a new ClassBreaksRenderer and redraw the map."
FontSize="14" Width="400" TextAlignment="Left" TextWrapping="Wrap" />
<Button Content="Change Renderer" HorizontalAlignment="Center" Margin="12,12,12,0"
Click="ChangeRendererButton_Click"/>
</StackPanel>
</Border>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -12,95 +12,95 @@

namespace ArcGISRuntimeSDKDotNet_DesktopSamples.Samples
{
/// <summary>
/// Sample shows how to create a ClassBreaksRenderer for a graphics layer. Earthquake data points are pulled from an online source and rendered using the GraphicsLayer ClassBreaksRenderer.
/// </summary>
/// <title>Class Breaks Renderer</title>
/// <summary>
/// Sample shows how to create a ClassBreaksRenderer for a graphics layer. Data points are pulled from an online source and rendered using the GraphicsLayer ClassBreaksRenderer.
/// </summary>
/// <title>Class Breaks Renderer</title>
/// <category>Symbology</category>
public partial class ClassBreaksRendererSample : UserControl
{
private Random _random = new Random();
private GraphicsOverlay _earthquakes;
{
private Random _random = new Random();
private GraphicsOverlay _cities;

/// <summary>Construct Class Breaks Renderer sample control</summary>
public ClassBreaksRendererSample()
{
InitializeComponent();
/// <summary>Construct Class Breaks Renderer sample control</summary>
public ClassBreaksRendererSample()
{
InitializeComponent();

_earthquakes = MyMapView.GraphicsOverlays["earthquakes"];
_cities = MyMapView.GraphicsOverlays["cities"];

MyMapView.ExtentChanged += MyMapView_ExtentChanged;
}
MyMapView.ExtentChanged += MyMapView_ExtentChanged;
}

// Load earthquake data
private async void MyMapView_ExtentChanged(object sender, EventArgs e)
{
try
{
MyMapView.ExtentChanged -= MyMapView_ExtentChanged;
await LoadEarthquakesAsync();
}
catch (Exception ex)
{
MessageBox.Show("Error loading earthquake data: " + ex.Message, "Class Breaks Renderer Sample");
}
}
// Load data
private async void MyMapView_ExtentChanged(object sender, EventArgs e)
{
try
{
MyMapView.ExtentChanged -= MyMapView_ExtentChanged;
await LoadDataAsync();
}
catch (Exception ex)
{
MessageBox.Show("Error loading data: " + ex.Message, "Class Breaks Renderer Sample");
}
}

// Change the graphics layer renderer to a new ClassBreaksRenderer
private void ChangeRendererButton_Click(object sender, RoutedEventArgs e)
{
SimpleMarkerStyle style = (SimpleMarkerStyle)_random.Next(0, 6);
// Change the graphics layer renderer to a new ClassBreaksRenderer
private void ChangeRendererButton_Click(object sender, RoutedEventArgs e)
{
SimpleMarkerStyle style = (SimpleMarkerStyle)_random.Next(0, 6);

_earthquakes.Renderer = new ClassBreaksRenderer()
{
Field = "magnitude",
Infos = new ClassBreakInfoCollection()
{
new ClassBreakInfo() { Minimum = 2, Maximum = 3, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 3, Maximum = 4, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 4, Maximum = 5, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 5, Maximum = 6, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 6, Maximum = 7, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 7, Maximum = 8, Symbol = GetRandomSymbol(style) },
}
};
}
_cities.Renderer = new ClassBreaksRenderer()
{
Field = "pop2000",
Infos = new ClassBreakInfoCollection()
{
new ClassBreakInfo() { Minimum = 0, Maximum = 50000, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 50000, Maximum = 100000, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 100000, Maximum = 250000, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 250000, Maximum = 500000, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 500000, Maximum = 1000000, Symbol = GetRandomSymbol(style) },
new ClassBreakInfo() { Minimum = 1000000, Maximum = 5000000, Symbol = GetRandomSymbol(style) },
}
};
}

// Load earthquakes from map service
private async Task LoadEarthquakesAsync()
{
var queryTask = new QueryTask(
new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0"));
var query = new Query(MyMapView.Extent)
{
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
Where = "magnitude > 2.0",
OutFields = new OutFields(new List<string> { "magnitude" })
};
var result = await queryTask.ExecuteAsync(query);
// Load data from map service
private async Task LoadDataAsync()
{
var queryTask = new QueryTask(
new Uri("http://sampleserver6.arcgisonline.com/ArcGIS/rest/services/USA/MapServer/0"));
var query = new Query(MyMapView.Extent)
{
ReturnGeometry = true,
OutSpatialReference = MyMapView.SpatialReference,
Where = "pop2000 > 50000",
OutFields = new OutFields(new List<string> { "pop2000" })
};
var result = await queryTask.ExecuteAsync(query);

_earthquakes.Graphics.Clear();
_earthquakes.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
}
_cities.Graphics.Clear();
_cities.Graphics.AddRange(result.FeatureSet.Features.OfType<Graphic>());
}

// Utility: Generate a random simple marker symbol
private SimpleMarkerSymbol GetRandomSymbol(SimpleMarkerStyle style)
{
return new SimpleMarkerSymbol()
{
Size = 12,
Color = GetRandomColor(),
Style = style
};
}
// Utility: Generate a random simple marker symbol
private SimpleMarkerSymbol GetRandomSymbol(SimpleMarkerStyle style)
{
return new SimpleMarkerSymbol()
{
Size = 12,
Color = GetRandomColor(),
Style = style
};
}

// Utility function: Generate a random System.Windows.Media.Color
private Color GetRandomColor()
{
var colorBytes = new byte[3];
_random.NextBytes(colorBytes);
return Color.FromRgb(colorBytes[0], colorBytes[1], colorBytes[2]);
}
}
// Utility function: Generate a random System.Windows.Media.Color
private Color GetRandomColor()
{
var colorBytes = new byte[3];
_random.NextBytes(colorBytes);
return Color.FromRgb(colorBytes[0], colorBytes[1], colorBytes[2]);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
<Page
x:Class="ArcGISRuntimeSDKDotNet_PhoneSamples.Samples.Symbology.ClassBreaksRendererSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ArcGISRuntimeSDKDotNet_PhoneSamples.Samples.Symbology"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="ArcGISRuntimeSDKDotNet_PhoneSamples.Samples.Symbology.ClassBreaksRendererSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ArcGISRuntimeSDKDotNet_PhoneSamples.Samples.Symbology"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:esri="using:Esri.ArcGISRuntime.Controls"
xmlns:layers="using:Esri.ArcGISRuntime.Layers"
xmlns:symb="using:Esri.ArcGISRuntime.Symbology"
mc:Ignorable="d"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
<Grid.Resources>
<symb:SimpleMarkerSymbol x:Key="mag2to3" Color="#FF0A57FC" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="mag3to4" Color="#FF1CA2A3" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="mag4to5" Color="#FF60AD12" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="mag5to6" Color="#FFFFFE0A" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="mag6to7" Color="#FFFDA208" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="mag7to8" Color="#FFFB5107" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop0to50K" Color="#FF0A57FC" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop50Kto100K" Color="#FF1CA2A3" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop100Kto250K" Color="#FF60AD12" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop250Kto500K" Color="#FFFFFE0A" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop500Kto1000K" Color="#FFFDA208" Size="12" Style="Triangle" />
<symb:SimpleMarkerSymbol x:Key="pop1000K" Color="#FFFB5107" Size="12" Style="Triangle" />
</Grid.Resources>

<esri:MapView x:Name="MyMapView" WrapAround="True">
<esri:Map>
<esri:Map.InitialViewpoint>
<esri:ViewpointExtent XMin="-15053000" YMin="2749000" XMax="-6540000" YMax="6590000" />
</esri:Map.InitialViewpoint>
<layers:ArcGISTiledMapServiceLayer
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
</esri:Map>
<esri:MapView.GraphicsOverlays>
<esri:GraphicsOverlay ID="earthquakes">
<esri:GraphicsOverlay ID="cities">
<esri:GraphicsOverlay.Renderer>
<symb:ClassBreaksRenderer Field="magnitude" >
<symb:ClassBreaksRenderer Field="pop2000" >
<symb:ClassBreaksRenderer.Infos>
<symb:ClassBreakInfo Minimum="2" Maximum="3" Symbol="{StaticResource mag2to3}" />
<symb:ClassBreakInfo Minimum="3" Maximum="4" Symbol="{StaticResource mag3to4}" />
<symb:ClassBreakInfo Minimum="4" Maximum="5" Symbol="{StaticResource mag4to5}" />
<symb:ClassBreakInfo Minimum="5" Maximum="6" Symbol="{StaticResource mag5to6}" />
<symb:ClassBreakInfo Minimum="6" Maximum="7" Symbol="{StaticResource mag6to7}" />
<symb:ClassBreakInfo Minimum="7" Maximum="8" Symbol="{StaticResource mag7to8}" />
<symb:ClassBreakInfo Minimum="0" Maximum="50000" Symbol="{StaticResource pop0to50K}" />
<symb:ClassBreakInfo Minimum="500000" Maximum="100000" Symbol="{StaticResource pop50Kto100K}" />
<symb:ClassBreakInfo Minimum="100000" Maximum="250000" Symbol="{StaticResource pop100Kto250K}" />
<symb:ClassBreakInfo Minimum="250000" Maximum="500000" Symbol="{StaticResource pop250Kto500K}" />
<symb:ClassBreakInfo Minimum="500000" Maximum="1000000" Symbol="{StaticResource pop500Kto1000K}" />
<symb:ClassBreakInfo Minimum="1000000" Maximum="5000000" Symbol="{StaticResource pop1000K}" />
</symb:ClassBreaksRenderer.Infos>
</symb:ClassBreaksRenderer>
</esri:GraphicsOverlay.Renderer>
</esri:GraphicsOverlay>
</esri:MapView.GraphicsOverlays>
</esri:MapView>


<Border Background="#CC000000" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="30" Padding="20">
<StackPanel>
<TextBlock Text="Earthquake points are rendered using the renderer of the graphics layer. Click Change Renderer to change the renderer to a new ClassBreaksRenderer and redraw the map."
FontSize="14" Width="296" TextWrapping="Wrap" />
<TextBlock Text="USA cities are rendered using the renderer of the graphics layer. Click Change Renderer to change the renderer to a new ClassBreaksRenderer and redraw the map."
FontSize="14" Width="296" TextWrapping="Wrap" />
<Button Content="Change Renderer" HorizontalAlignment="Center" Margin="0,12,0,0"
Click="ChangeRendererButton_Click"/>
Click="ChangeRendererButton_Click"/>
</StackPanel>
</Border>
</Grid>
Expand Down
Loading

0 comments on commit b602163

Please sign in to comment.