<!-- Overview Map Window --> <userControls:WindowPanel x:Name="OverviewMapPanel" Width="212" Height="231" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,89,10,0"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <ei:ChangePropertyAction PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> <esri:OverviewMap x:Name="OVMap" Margin="0" Map="{Binding ElementName=Map}"> <esri:OverviewMap.Layer> <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> </esri:OverviewMap.Layer> </esri:OverviewMap> <userControls:WindowPanel.ContentTitle> <StackPanel Orientation="Horizontal"> <Image Source="Images/i_overview.png" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill" Width="20" Height="20" Margin="5,2,0,0" /> <TextBlock Foreground="White" FontSize="12" Text="Overview Map" Width="100" TextWrapping="NoWrap" Height="Auto" HorizontalAlignment="Left" Margin="5,3,0,0" /> </StackPanel> </userControls:WindowPanel.ContentTitle> </userControls:WindowPanel> <!-- Magnifying Glass --> <esri:MagnifyingGlass x:Name="MagnifyingGlass" HorizontalAlignment="Left" VerticalAlignment="Top" Map="{Binding ElementName=Map}" Margin="50,150,0,0" Visibility="Collapsed"> <esri:MagnifyingGlass.Layer> <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> </esri:MagnifyingGlass.Layer> </esri:MagnifyingGlass> <!-- About Window --> <userControls:WindowPanel x:Name="AboutWindow" Width="375" Height="150" Visibility="Collapsed" Effect="{StaticResource dropShadow}" Background="{StaticResource CommonBackgroundBrush}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"> <StackPanel Orientation="Vertical"> <TextBlock Style="{StaticResource Title}" TextWrapping="NoWrap" Text="{StaticResource ApplicationTitle}" Width="Auto" Height="Auto" Margin="5,3,0,0" /> <TextBlock Style="{StaticResource Subtitle}" TextWrapping="NoWrap" Text="{StaticResource ApplicationSubtitle}" Width="Auto" Height="Auto" Margin="5,1,0,0" /> <Line X1="5" Y1="50" X2="355" Y2="50" Stroke="White" StrokeThickness="0.25" /> <TextBlock Foreground="Yellow" FontSize="11" Width="Auto" TextWrapping="NoWrap" Text="{StaticResource ApplicationInfo}" Height="Auto" HorizontalAlignment="Left" Margin="5,3,0,0" /> </StackPanel> <userControls:WindowPanel.ContentTitle> <StackPanel Orientation="Horizontal"> <Image Source="Images/logo.png" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill" Width="20" Height="20" Margin="5,2,0,0" /> <TextBlock Foreground="White" FontSize="12" Text="About" Width="100" TextWrapping="NoWrap" Height="Auto" HorizontalAlignment="Left" Margin="5,3,0,0" /> </StackPanel> </userControls:WindowPanel.ContentTitle> </userControls:WindowPanel> </Grid> </UserControl>
<!-- The SubMenus --> <Grid x:Name="myMenuItems" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,112"> <Border Style="{StaticResource CommonBorder}" Padding="10,3,10,3"> <StackPanel> <Button x:Name="myMenuItem1" Style="{StaticResource MenuItem}" ToolTipService.ToolTip="Your First Menu Here!" Content="LayerDef 1" Click="myMenuItem1_Click" /> <Button x:Name="myMenuItem2" Style="{StaticResource MenuItem}" ToolTipService.ToolTip="Your Second Menu Here!" Content="LayerDef 2" Click="myMenuItem2_Click" /> <Button x:Name="myMenuItem3" Style="{StaticResource MenuItem}" ToolTipService.ToolTip="Your Third Menu Here!" Content="Clear LayerDef" Click="myMenuItem3_Click" /> </StackPanel> </Border> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeave"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> <i:EventTrigger EventName="Loaded"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> </Grid> <!-- StackPanel containing the Base Map Switcher and the Application Toolbar --> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,5,0" VerticalAlignment="Top" > <!-- Base Map Switcher --> <Border x:Name="BaseMapSwitcher" Style="{StaticResource CommonBorder}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="5"> <StackPanel Orientation="Horizontal" Margin="5"> <RadioButton Content="Streets" IsChecked="True" ToolTipService.ToolTip="Worldwide Street Map" GroupName="BaseLayer" Margin="5,0,0,0" Foreground="White" FontSize="11" > <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <actions:SetLayerUrlAction TargetName="Map" LayerID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="Topo" GroupName="BaseLayer" ToolTipService.ToolTip="United States Topographic Map" Margin="5,0,0,0" Foreground="White" FontSize="11" > <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <actions:SetLayerUrlAction TargetName="Map" LayerID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> <RadioButton Content="Imagery" ToolTipService.ToolTip="Worldwide Satellite Imagery Map" GroupName="BaseLayer" Margin="5,0,0,0" Foreground="White" FontSize="11" > <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <actions:SetLayerUrlAction TargetName="Map" LayerID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/> </i:EventTrigger> </i:Interaction.Triggers> </RadioButton> </StackPanel> </Border> <!-- Toolbar --> <Grid Margin="5"> <userControls:CollapsiblePanel x:Name="MainToolbar" IsExpanded="True" RenderTransformOrigin="1,0" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="0,0,5,0"> <Grid HorizontalAlignment="Left" Effect="{StaticResource dropShadow}"> <Border Style="{StaticResource CommonBorder}" Margin="0,0,0,18" Effect="{x:Null}" /> <StackPanel Orientation="Horizontal" Margin="0,7,15,0"> <Button x:Name="btnToggleBaseMapSwitcher" Style="{StaticResource ToolbarButton}" ToolTipService.ToolTip="Toggle visibility of the base map switcher"> <Button.Content> <Image Source="Images/i_clickglobe.png" Stretch="Fill" /> </Button.Content> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <actions:ToggleVisibilityAction TargetName="BaseMapSwitcher" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button x:Name="btnToggleOverviewMap" Style="{StaticResource ToolbarButton}" ToolTipService.ToolTip="Toggle visibility of the overview map"> <Button.Content> <Image Source="Images/i_overview.png" Stretch="Fill" /> </Button.Content> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <actions:ToggleVisibilityAction TargetName="OverviewMapPanel" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button x:Name="btnToggleMagnifyingGlass" Style="{StaticResource ToolbarButton}" ToolTipService.ToolTip="Toggle visibility of the magnifying glass"> <Button.Content> <Image Source="Images/i_magnifyglass.png" Stretch="Fill" /> </Button.Content> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <actions:ToggleVisibilityAction TargetName="MagnifyingGlass" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> </StackPanel> </Grid> </userControls:CollapsiblePanel> <Image Source="Images/i_tools.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="Fill" Height="30" Width="30" Margin="-5" ToolTipService.ToolTip="Expand/Collapse Toolbar"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <actions:ToggleCollapseAction TargetName="MainToolbar" /> </i:EventTrigger> </i:Interaction.Triggers> </Image> </Grid> </StackPanel> <!-- Navigator --> <esri:Navigation x:Name="Navigator" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="40,0,0,30" Map="{Binding ElementName=Map}" /> <!-- Scale Bar --> <userControls:ScaleBar x:Name="ScaleBar" MapUnit="Meters" Map="{Binding ElementName=Map}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="20,0,0,10" />
<UserControl x:Class="ESRIStandardMapApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" mc:Ignorable="d" d:DesignWidth="780" d:DesignHeight="480" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" xmlns:userControls="clr-namespace:ESRI.ArcGIS.SilverlightMapApp" xmlns:actions="clr-namespace:ESRI.ArcGIS.SilverlightMapApp.Actions"> <Grid x:Name="LayoutRoot"> <!-- Map Control --> <esri:Map x:Name="Map" Background="White"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> <esri:ArcGISTiledMapServiceLayer ID="BaseLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> <esri:ArcGISDynamicMapServiceLayer Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer"> <esri:ArcGISDynamicMapServiceLayer.LayerDefinitions> <!-- LayerID="0" is the Earthquakes1970 layer. The Definition only displays earth quakes that have an Magnitude greater than 6. The field Magnitude is of type esriFieldTypeDouble. --> <!-- <esri:LayerDefinition LayerID="0" Definition="Magnitude > 6" /> --> <!-- Another example where the Name of the earth quake event is to contains the letters 'CHINA'. Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. --> <!-- <esri:LayerDefinition LayerID="0" Definition="Name LIKE 'CHINA'" /> --> <!-- Another example where the Name of the earth quake event is exactly matches the letters 'VENEZUELA'. Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. --> <!-- <esri:LayerDefinition LayerID="0" Definition="Name = 'VENEZUELA'" /> --> <!-- Another example where the earth quake events are displayed if they occured after January 15, 2008. The field Date_ is of type esriFieldTypeDate. --> <!-- <esri:LayerDefinition LayerID="0" Definition="Date_ > DATE '1/15/2008'" />--> </esri:ArcGISDynamicMapServiceLayer.LayerDefinitions> </esri:ArcGISDynamicMapServiceLayer> <!--<esri:ArcGISDynamicMapServiceLayer ID="Base Map" Url="http://ccmcd-gis/ArcGIS/rest/services/Citrus_Base/MapServer" />--> </esri:Map> <!-- Main Menu --> <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" > <userControls:CollapsiblePanel x:Name="MainManu" IsExpanded="True" RenderTransformOrigin="0,0" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"> <Border Style="{StaticResource CommonBorder}"> <StackPanel Margin="3"> <Grid x:Name="BannerGrid" Grid.Row="0" Margin="30,0"> <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="3" /> <RowDefinition Height="17" /> </Grid.RowDefinitions> <!-- Application Title --> <TextBlock x:Name="title" Margin="0,0,15,0" Style="{StaticResource Title}" Text="{StaticResource ApplicationTitle}" Grid.Row="0" /> <Rectangle x:Name="separatorBar" Fill="CornflowerBlue" Grid.Row="1" /> <!-- Application Subtitle --> <TextBlock x:Name="subtitle" Style="{StaticResource Subtitle}" Text="{StaticResource ApplicationSubtitle}" Grid.Row="2" /> </Grid> <Canvas HorizontalAlignment="Left" Height="25" Width="Auto" VerticalAlignment="Bottom" Margin="10,10,10,-5"> <StackPanel Orientation="Horizontal"> <Button x:Name="myMenu" Style="{StaticResource MenuButton}" ToolTipService.ToolTip="Menu"> <Button.Content> <Image Source="Images/i_globe.png" Stretch="Fill" /> </Button.Content> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Visible</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button x:Name="btnAbout" Style="{StaticResource MenuButton}" ToolTipService.ToolTip="About ESRI ArcGIS Mapping Application"> <Button.Content> <Image Source="Images/i_about.png" Stretch="Fill" /> </Button.Content> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> <i:EventTrigger EventName="Click"> <actions:ToggleVisibilityAction TargetName="AboutWindow" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> </StackPanel> </Canvas> </StackPanel> </Border> </userControls:CollapsiblePanel> <Image Source="Images/logo.png" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Fill" Height="40" Width="40" Margin="-10" ToolTipService.ToolTip="Expand/Collapse Menu Bar"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <actions:ToggleCollapseAction TargetName="MainManu" /> </i:EventTrigger> <i:EventTrigger EventName="MouseLeftButtonDown"> <ei:ChangePropertyAction TargetName="myMenuItems" PropertyName="Visibility"> <ei:ChangePropertyAction.Value> <Visibility>Collapsed</Visibility> </ei:ChangePropertyAction.Value> </ei:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> </Image> </Grid>
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Browser; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Markup; using System.Windows.Shapes; using System.ComponentModel; using ESRI.ArcGIS.Client; using System.Windows.Controls.Primitives; namespace ESRIStandardMapApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void myMenuItem1_Click(object sender, RoutedEventArgs e) { // The myArcGISDynamicMapServiceLayer (an ArcGISDynamicServiceLayer object) and TextBlock_LayerDefinitions // (a TextBlock object) were defined previously in the XAML or code-behind. // Get the layer in the LayerInfo collection. ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ArcGISDynamicMapServiceLayer)Map.Layers[1]; // LayerDefinition (Read/Write) // This is how to set (i.e. Write) a LayerDefinition. // -------------------------------------------------- // Set the .LayerDefinition for the .LayerID = 0 (the Earthquakes1970 layer). By default no LayerDefinition // is set unless explicitly set on the server. ESRI.ArcGIS.Client.LayerDefinition myDefinition = new ESRI.ArcGIS.Client.LayerDefinition(); myDefinition.LayerID = 0; // The Definition only displays earth quakes that have an Magnitude greater than 6. // The field Magnitude is of type esriFieldTypeDouble. myDefinition.Definition = "Magnitude > 6"; // Another example where the Name of the earth quake event is to contains the letters 'CHINA'. // Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. //myDefinition.Definition = "Name LIKE 'CHINA'"; // Another example where the Name of the earth quake event is exactly matches the letters 'VENEZUELA'. // Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. //myDefinition.Definition = "Name = 'VENEZUELA'"; // Another example where the earth quake events are displayed if they occured after January 15, 2008. // The field Date_ is of type esriFieldTypeDate. //myDefinition.Definition = "Date_ > DATE '1/15/2008'"; // Create an ObservableCollection and add the .Definition to it. System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection2 = new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>(); myObservableCollection2.Add(myDefinition); // Apply the custom LayerDefinition myArcGISDynamicMapServiceLayer.LayerDefinitions = myObservableCollection2; myArcGISDynamicMapServiceLayer.Refresh(); } private void myMenuItem2_Click(object sender, RoutedEventArgs e) { // The myArcGISDynamicMapServiceLayer (an ArcGISDynamicServiceLayer object) and TextBlock_LayerDefinitions // (a TextBlock object) were defined previously in the XAML or code-behind. // Get the layer in the LayerInfo collection. ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ArcGISDynamicMapServiceLayer)Map.Layers[1]; // LayerDefinition (Read/Write) // This is how to set (i.e. Write) a LayerDefinition. // -------------------------------------------------- // Set the .LayerDefinition for the .LayerID = 0 (the Earthquakes1970 layer). By default no LayerDefinition // is set unless explicitly set on the server. ESRI.ArcGIS.Client.LayerDefinition myDefinition = new ESRI.ArcGIS.Client.LayerDefinition(); myDefinition.LayerID = 0; // The Definition only displays earth quakes that have an Magnitude greater than 6. // The field Magnitude is of type esriFieldTypeDouble. myDefinition.Definition = "Name = 'VENEZUELA'"; // Another example where the Name of the earth quake event is to contains the letters 'CHINA'. // Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. //myDefinition.Definition = "Name LIKE 'CHINA'"; // Another example where the Name of the earth quake event is exactly matches the letters 'VENEZUELA'. // Note: the Definition is case sensitive. The field Name is of type esriFieldTypeString. //myDefinition.Definition = "Name = 'VENEZUELA'"; // Another example where the earth quake events are displayed if they occured after January 15, 2008. // The field Date_ is of type esriFieldTypeDate. //myDefinition.Definition = "Date_ > DATE '1/15/2008'"; // Create an ObservableCollection and add the .Definition to it. System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection2 = new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>(); myObservableCollection2.Add(myDefinition); // Apply the custom LayerDefinition myArcGISDynamicMapServiceLayer.LayerDefinitions = myObservableCollection2; myArcGISDynamicMapServiceLayer.Refresh(); } void ReadLayerDefs() { // This is how to get (i.e. Read) a LayerDefiniton. // The TextBlock_LayerDefinitions (a TextBlock object) was previously set in XAML or code-behind. // ---------------------------------------------------------------------------------------------- // Get the existing LayerDefinitions collection. ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ArcGISDynamicMapServiceLayer)Map.Layers[1]; System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection = myArcGISDynamicMapServiceLayer.LayerDefinitions; if (myObservableCollection.Count > 0) { // Get the first LayerDefinition ESRI.ArcGIS.Client.LayerDefinition myLayerDefinition = myObservableCollection[0]; // Display some textual information about the LayerDefinition. MessageBox.Show("For Layer: " + myLayerDefinition.LayerID.ToString() + ". The Defintion is: " + myLayerDefinition.Definition); } else { MessageBox.Show("[NO LayerDefinitions SET]"); } } private void myMenuItem3_Click(object sender, RoutedEventArgs e) { // Get the layer in the LayerInfo collection. ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (ArcGISDynamicMapServiceLayer)Map.Layers[1]; // Create an ObservableCollection and add the .Definition to it. System.Collections.ObjectModel.ObservableCollection<LayerDefinition> myObservableCollection2 = new System.Collections.ObjectModel.ObservableCollection<LayerDefinition>(); // myObservableCollection2.Add(myDefinition); // Apply the custom LayerDefinition myArcGISDynamicMapServiceLayer.LayerDefinitions = myObservableCollection2; myArcGISDynamicMapServiceLayer.Refresh(); } } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.