Опубликован: 01.11.2011 | Доступ: свободный | Студентов: 1424 / 63 | Оценка: 3.84 / 3.44 | Длительность: 15:38:00
Специальности: Программист
Практическая работа 20:
Использование картографического сервиса (Silverlight)
Упражнение 28.2. Карта с государственными границами
В данной работе мы создадим более сложную карту. Изначально на ней показаны государственные границы, при увеличении масштаба также становится виден рельеф местности.
Создаем приложение Silverlight p20_2. Повторяем действия из предыдущего упражнения.
Код xaml:
<UserControl x:Class="p20_2.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"
mc:Ignorable="d"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" >
<esri:Map x:Name="MyMap">
<esri:ArcGISTiledMapServiceLayer ID="MyLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
</esri:Map>
</Grid>
</UserControl>
Результат:
Упражнение 28.3. Создание динамических слоев
Создаем проект Silverlight p20_3. Повторяем действия из предыдущего упражнения.
Код xaml:
<UserControl x:Class="p20_3.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"
mc:Ignorable="d"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White" >
<esri:Map x:Name="MyMap" >
<esri:ArcGISDynamicMapServiceLayer ID="MyLayer"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" />
</esri:Map>
</Grid>
</UserControl>
Результат:
Упражнение 28.4. Динамические и Плиточные Слои
Создаем проект Silverlight p20_4. Повторяем действия из предыдущего упражнения.
Код xaml:
<UserControl x:Class="p20_4.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"
mc:Ignorable="d"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" >
<esri:Map x:Name="MyMap" Extent="-120,20,-90,60">
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer" Opacity="0.6"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/>
</esri:Map>
</Grid>
</UserControl>
Результат:
Упражнение 28.5. Список слоев
В данном приложении пользователь может также, как в программе ArcGIS, активизировать слои.
Создаем проект Silverlight p20_5. Повторяем действия из предыдущего упражнения.
Код xaml:
<UserControl x:Class="p20_5.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"
mc:Ignorable="d"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" >
<esri:Map x:Name="MyMap" Extent="-120,20,-90,60">
<esri:ArcGISTiledMapServiceLayer ID="Street Map"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="State,City,Highway" Opacity="0.6"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="California" Opacity="0.4"
Url="http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer" />
</esri:Map>
<Border Background="#995C90B2" BorderThickness="1" CornerRadius="5"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="20" Padding="5" BorderBrush="Black" >
<ListBox x:Name="MyList" ItemsSource="{Binding ElementName=MyMap, Path=Layers}" Margin="3">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="2">
<!--Layer visibility checkbox-->
<CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" />
<!--Opacity slider-->
<Slider Minimum="0" Maximum="1" Width="30"
Value="{Binding Opacity, Mode=TwoWay}" Height="22" />
<!--Layer name-->
<TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,2,0" >
<!-- Tooltip on hover-->
<ToolTipService.ToolTip>
<StackPanel MaxWidth="400">
<TextBlock FontWeight="Bold" Text="{Binding CopyrightText}" TextWrapping="Wrap" />
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
</StackPanel>
</ToolTipService.ToolTip>
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</Grid>
</UserControl>
Листинг
.
Результат:




