您的位置:首页 > 其它

ArcGIS API for Silverlight加载BingMap遥感地图

2012-11-20 19:59 686 查看
<UserControl x:Class="BingMap.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"
xmlns:bing="clr-namespace:ESRI.ArcGIS.Client.Bing;assembly=ESRI.ArcGIS.Client.Bing" d:DesignWidth="718" Loaded="UserControl_Loaded">

<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="MyMap" IsLogoVisible="False" WrapAround="True" Extent="13628957,3439071,12638037,3572727"/>
<Border BorderBrush="#FF748ECC" BorderThickness="2" Height="61" Margin="0,26,8,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="120" CornerRadius="5" Background="#FF024BFF" Canvas.ZIndex="2">
<Grid Margin="6,0,15,6">
<Border HorizontalAlignment="Center" Margin="0,0,0,20" Width="68">
<HyperlinkButton x:Name="hlb1" Content="卫星地图" FontSize="16" FontWeight="Bold" Foreground="Red" Height="25" VerticalAlignment="Bottom" Click="hlb1_Click"/>
</Border>
<Border HorizontalAlignment="Center" Height="25" Margin="0,0,0,-5" VerticalAlignment="Bottom" Width="68" >
<HyperlinkButton x:Name="hlb2" Content="遥测分析" FontSize="16" FontWeight="Bold" Foreground="White" Click="hlb2_Click"/>
</Border>
</Grid>
</Border>
<Image x:Name="Image1" Source="Images/yc2.jpg" Cursor="Hand" Margin="0" Stretch="UniformToFill"/>
<!--<esri:Attribution Layers="{Binding Layers, ElementName=myMap}" Margin="10" VerticalAlignment="Top" />-->
</Grid>
</UserControl>

<!--13628957,3439071,12638037,3572727-->

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Json;
using ESRI.ArcGIS.Client.Bing;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using System.Windows.Media.Imaging;

namespace BingMap
{
public partial class MainPage : UserControl
{
public string bingToken = "AkzZURoD0H2Sle6Nq_DE7pm7F3xOc8S3CjDTGNWkz1EFlJJkcwDKT1KcNcmYVINU";
public MainPage()
{
InitializeComponent();
this.Image1.Visibility = Visibility.Collapsed;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
WebClient webClient = new WebClient();
string uri = string.Format("http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?supressStatus=true&key={0}", bingToken);

webClient.OpenReadCompleted += (s, a) =>
{
if (a.Error == null)
{
JsonValue jsonResponse = JsonObject.Load(a.Result);
string authenticationResult = jsonResponse["authenticationResultCode"];
a.Result.Close();

if (authenticationResult == "ValidCredentials")
{
ESRI.ArcGIS.Client.Bing.TileLayer tileLayer = new TileLayer()
{
ID = "BingLayer",
LayerStyle = TileLayer.LayerType.AerialWithLabels,
ServerType = ServerType.Production,
Token = bingToken
};
MyMap.Layers.Add(tileLayer);
}
}
};
webClient.OpenReadAsync(new System.Uri(uri));
}

private void hlb1_Click(object sender, System.Windows.RoutedEventArgs e)
{
// 默认显示的是卫星地图,此时遥感图不显示,并且遥感地图字体显示白色
this.MyMap.Visibility = Visibility.Visible;
this.Image1.Visibility = Visibility.Collapsed;
this.hlb1.Foreground = new SolidColorBrush(Colors.Red);
this.hlb2.Foreground = new SolidColorBrush(Colors.White);
}

private void hlb2_Click(object sender, System.Windows.RoutedEventArgs e)
{
// 遥感图显示,卫星地图不显示
this.MyMap.Visibility = Visibility.Collapsed;
this.Image1.Visibility = Visibility.Visible;
this.hlb1.Foreground = new SolidColorBrush(Colors.White);
this.hlb2.Foreground = new SolidColorBrush(Colors.Red);
}
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐