ArcGIS API for Silverlight加载BingMap遥感地图

简介: ...
<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);
        }
    }
}


相关文章
|
1月前
|
缓存 API 定位技术
使用Python调用百度地图API实现地址查询
使用Python调用百度地图API实现地址查询
90 0
|
8月前
|
定位技术 API 开发工具
Android 按照步骤接入百度地图API,定位显示不了解决办法
Android 按照步骤接入百度地图API,定位显示不了解决办法
225 0
|
9月前
|
数据可视化 搜索推荐 JavaScript
数据可视化大屏百度地图区域掩膜MapMask实现地图指定区域非省市县行政区显示的实战案例解析(JavaScript API GL、个性化地图定制、指定区域经纬度拾取转化)
数据可视化大屏百度地图区域掩膜MapMask实现地图指定区域非省市县行政区显示的实战案例解析(JavaScript API GL、个性化地图定制、指定区域经纬度拾取转化)
685 0
|
4月前
|
机器学习/深度学习 弹性计算 算法
ArcGIS Pro遥感影像分类:随机森林、支持向量机方法
ArcGIS Pro遥感影像分类:随机森林、支持向量机方法
|
3月前
|
JSON JavaScript 定位技术
Vue中使用echarts@4.x中国地图及AMap相关API的使用
Vue中使用echarts@4.x中国地图及AMap相关API的使用
145 0
Vue中使用echarts@4.x中国地图及AMap相关API的使用
|
4月前
|
SQL 存储 DataWorks
DataWorks中API、desc、数据地图,这3个怎么对起来?
DataWorks中API、desc、数据地图,这3个怎么对起来?
40 0
|
4月前
|
定位技术 Python
ArcGIS批量拼接大量栅格遥感影像:Mosaic工具
ArcGIS批量拼接大量栅格遥感影像:Mosaic工具
|
4月前
|
Serverless 定位技术 Windows
ArcGIS中ArcMap快速自动计算单一波段或多波段栅格遥感影像NDVI的方法
ArcGIS中ArcMap快速自动计算单一波段或多波段栅格遥感影像NDVI的方法
|
4月前
|
存储 机器学习/深度学习 数据挖掘
ArcGIS中ArcMap栅格遥感影像的监督分类
ArcGIS中ArcMap栅格遥感影像的监督分类
|
4月前
|
存储 定位技术
ArcGIS中ArcMap时间滑块功能对长时间序列栅格遥感影像进行动态显示并生成视频或动图
ArcGIS中ArcMap时间滑块功能对长时间序列栅格遥感影像进行动态显示并生成视频或动图

热门文章

最新文章