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);
        }
    }
}


相关文章
|
人工智能 数据可视化 API
ArcGIS API for Python
ArcGIS API for Python
215 0
|
JavaScript 前端开发 应用服务中间件
Arcgis api for javascript 详细部署
Arcgis api for javascript 详细部署
|
人工智能 数据可视化 数据管理
ArcGIS API for Python
ArcGIS API for Python
274 0
|
JavaScript 前端开发 定位技术
ArcGIS API For JavaScript官方文档(六)之设置范围
ArcGIS API For JavaScript官方文档(六)之设置范围
|
API 定位技术 Android开发
百度地图移动版API 1.2.2版本(Android)地图偏移的最佳解决办法
Import import com.baidu.mapapi.CoordinateConvert;import com.baidu.mapapi.GeoPoint; Code GeoPoint p = new GeoPoint(x, y);GeoPoint p2 = CoordinateConvert.
783 0
|
4月前
|
缓存 监控 前端开发
顺企网 API 开发实战:搜索 / 详情接口从 0 到 1 落地(附 Elasticsearch 优化 + 错误速查)
企业API开发常陷参数、缓存、错误处理三大坑?本指南拆解顺企网双接口全流程,涵盖搜索优化、签名验证、限流应对,附可复用代码与错误速查表,助你2小时高效搞定开发,提升响应速度与稳定性。
|
4月前
|
JSON 算法 API
Python采集淘宝商品评论API接口及JSON数据返回全程指南
Python采集淘宝商品评论API接口及JSON数据返回全程指南
|
5月前
|
数据可视化 测试技术 API
从接口性能到稳定性:这些API调试工具,让你的开发过程事半功倍
在软件开发中,接口调试与测试对接口性能、稳定性、准确性及团队协作至关重要。随着开发节奏加快,传统方式已难满足需求,专业API工具成为首选。本文介绍了Apifox、Postman、YApi、SoapUI、JMeter、Swagger等主流工具,对比其功能与适用场景,并推荐Apifox作为集成度高、支持中文、可视化强的一体化解决方案,助力提升API开发与测试效率。
|
4月前
|
JSON API 数据安全/隐私保护
Python采集淘宝拍立淘按图搜索API接口及JSON数据返回全流程指南
通过以上流程,可实现淘宝拍立淘按图搜索的完整调用链路,并获取结构化的JSON商品数据,支撑电商比价、智能推荐等业务场景。
|
5月前
|
JSON 前端开发 API
如何调用体育数据足篮接口API
本文介绍如何调用体育数据API:首先选择可靠服务商并注册获取密钥,接着阅读文档了解基础URL、端点、参数及请求头,然后使用Python等语言发送请求、解析JSON数据,最后将数据应用于Web、App或分析场景,同时注意密钥安全、速率限制与错误处理。
581 152