ArcGIS API for Silverlight 加载google地图

简介:  using System;using System.Net;using System.

 

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Syit.CommonClass
{
    public static class ColorRevert
    {
        #region 颜色转换

        public static Color ToColor(this string colorName)
        {
            if (colorName.StartsWith("#"))
                colorName = colorName.Replace("#", string.Empty);
            int v = int.Parse(colorName, System.Globalization.NumberStyles.HexNumber);
            return new Color()
            {
                A = Convert.ToByte((v >> 24) & 255),
                R = Convert.ToByte((v >> 16) & 255),
                G = Convert.ToByte((v >> 8) & 255),
                B = Convert.ToByte((v >> 0) & 255)
            };
        }

        public static int ToArgb(this Color color)
        {
            int argb = color.A << 24;
            argb += color.R << 16;
            argb += color.G << 8;
            argb += color.B;
            return argb;
        }

        #endregion
    }
}


 

 private void btography_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        private void btography_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //设置背景颜色
            this.rect1.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FFF29536"));
            this.rect2.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            this.rect3.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            setSelectedLinearGradientBrush(rect1);
            setUnSelectedLinearGradientBrush(rect2);
            setUnSelectedLinearGradientBrush(rect3);
            //设置地图显示与隐藏
            topographyLayer.Visible = true; //google地形图
            roadLayer.Visible = false; //google交通图
            sateliateLayer.Visible = false; //google卫星图
            sateliateTextLayer.Visible = false; //google卫星图文字
        }

        private void broad_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        private void broad_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //设置背景颜色
            this.rect1.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            this.rect2.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FFF29536"));
            this.rect3.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            setUnSelectedLinearGradientBrush(rect1);
            setSelectedLinearGradientBrush(rect2);
            setUnSelectedLinearGradientBrush(rect3);
            //设置地图显示与隐藏
            topographyLayer.Visible = false; //google地形图
            roadLayer.Visible = true; //google交通图
            sateliateLayer.Visible = false; //google卫星图
            sateliateTextLayer.Visible = false; //google卫星图文字
        }

        private void bsateliate_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        private void bsateliate_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //设置背景颜色
            this.rect1.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            this.rect2.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));
            this.rect3.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FFF29536"));
            setUnSelectedLinearGradientBrush(rect1);
            setUnSelectedLinearGradientBrush(rect2);
            setSelectedLinearGradientBrush(rect3);
            //设置地图显示与隐藏
            topographyLayer.Visible = false; //google地形图
            roadLayer.Visible = false; //google交通图
            sateliateLayer.Visible = true; //google卫星图
            sateliateTextLayer.Visible = true; //google卫星图文字
        }

        //选中状态
        public void setSelectedLinearGradientBrush(Rectangle rect)
        {
            //设置stroke值
            rect.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FFF29536"));

            //设置渐变色
            GradientStop gs = new GradientStop();
            gs.Offset = 0.0;
            gs.Color = ColorRevert.ToColor("#FFFDF6DF");
            GradientStop gs1 = new GradientStop();
            gs1.Offset = 1.0;
            gs1.Color = Colors.White;
            GradientStop gs2 = new GradientStop();
            gs2.Offset = 0.5;
            gs2.Color = ColorRevert.ToColor("#FFF9E8B2");
            GradientStop gs3 = new GradientStop();
            gs3.Offset = 0.5;
            gs3.Color = ColorRevert.ToColor("#FFFFD75D");
            LinearGradientBrush lgb = new LinearGradientBrush();
            lgb.StartPoint = new Point(0.5, 0);
            lgb.EndPoint = new Point(0.5, 1);
            lgb.GradientStops.Add(gs);
            lgb.GradientStops.Add(gs1);
            lgb.GradientStops.Add(gs2);
            lgb.GradientStops.Add(gs3);
            rect.Fill = lgb;
        }

        //未选中状态
        public void setUnSelectedLinearGradientBrush(Rectangle rect)
        {
            //设置stroke值
            rect.Stroke = new SolidColorBrush(ColorRevert.ToColor("#FF7392BD"));

            //设置渐变色
            GradientStop gs = new GradientStop();
            gs.Offset = 0.0;
            gs.Color = ColorRevert.ToColor("#FFF5F6FB");
            GradientStop gs1 = new GradientStop();
            gs1.Offset = 1.0;
            gs1.Color = ColorRevert.ToColor("#FFE6EDFC");
            GradientStop gs2 = new GradientStop();
            gs2.Offset = 0.5;
            gs2.Color = ColorRevert.ToColor("#FFE6EBF5");
            GradientStop gs3 = new GradientStop();
            gs3.Offset = 0.5;
            gs3.Color = ColorRevert.ToColor("#FFD7E3F7");
            LinearGradientBrush lgb = new LinearGradientBrush();
            lgb.StartPoint = new Point(0.5, 0);
            lgb.EndPoint = new Point(0.5, 1);
            lgb.GradientStops.Add(gs);
            lgb.GradientStops.Add(gs1);
            lgb.GradientStops.Add(gs2);
            lgb.GradientStops.Add(gs3);
            rect.Fill = lgb;
        }


 

<Border HorizontalAlignment="Left" Margin="50,5,0,0" Width="230" BorderThickness="1" CornerRadius="5" VerticalAlignment="Top">
            <Border.Effect>
                <DropShadowEffect Direction="-90" Color="#FF4D4D4D" ShadowDepth="4"/>
            </Border.Effect>
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFDDF1FD" Offset="0"/>
                    <GradientStop Color="#FFCAE9FC" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid HorizontalAlignment="Left" Width="229">
                <Border x:Name="btography" HorizontalAlignment="Left" Margin="16,4,0,4" Width="64" MouseLeftButtonDown="btography_MouseLeftButtonDown" MouseLeftButtonUp="btography_MouseLeftButtonUp">
                    <Grid>
                        <Rectangle Stroke="#FFF29536" RadiusX="1" RadiusY="1" x:Name ="rect1">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFDF6DF" Offset="0"/>
                                    <GradientStop Color="White" Offset="1"/>
                                    <GradientStop Color="#FFF9E8B2" Offset="0.5"/>
                                    <GradientStop Color="#FFFFD75D" Offset="0.5"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Margin="16,6,13,2" TextWrapping="Wrap" Text="地形" Foreground="#FF0B333C" FontWeight="Bold" FontSize="14.667" FontFamily="SimSun"/>
                    </Grid>
                </Border>
                <Border x:Name="broad" Margin="84,4,81,4" MouseLeftButtonDown="broad_MouseLeftButtonDown" MouseLeftButtonUp="broad_MouseLeftButtonUp">
                    <Grid>
                        <Rectangle Stroke="#FF7392BD" RadiusX="1" RadiusY="1" x:Name ="rect2">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFF5F6FB" Offset="0"/>
                                    <GradientStop Color="#FFE6EDFC" Offset="1"/>
                                    <GradientStop Color="#FFE6EBF5" Offset="0.5"/>
                                    <GradientStop Color="#FFD7E3F7" Offset="0.5"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Margin="17,6,11,2" TextWrapping="Wrap" Text="街道" Foreground="#FF0B333C" FontWeight="Bold" FontSize="14.667" FontFamily="SimSun"/>
                    </Grid>
                </Border>
                <Border x:Name="bsateliate" HorizontalAlignment="Right" Margin="0,4,14,4" Width="64" MouseLeftButtonDown="bsateliate_MouseLeftButtonDown" MouseLeftButtonUp="bsateliate_MouseLeftButtonUp">
                    <Grid>
                        <Rectangle Stroke="#FF7392BD" RadiusX="1" RadiusY="1" x:Name ="rect3">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFF5F6FB" Offset="0"/>
                                    <GradientStop Color="#FFE6EDFC" Offset="1"/>
                                    <GradientStop Color="#FFE6EBF5" Offset="0.5"/>
                                    <GradientStop Color="#FFD7E3F7" Offset="0.5"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Margin="18,6,12,2" TextWrapping="Wrap" Text="影像" Foreground="#FF0B333C" FontWeight="Bold" FontSize="14.667" FontFamily="SimSun"/>
                    </Grid>
                </Border>
            </Grid>
        </Border>

相关文章
|
6月前
|
人工智能 Java API
Google Gemini API 接口调用方法
Google 最近发布的 Gemini 1.0 AI 模型通过其升级版,Gemini,标志着公司迄今为止最为强大和多功能的人工智能技术的突破。
|
6月前
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
Google Earth Engine(GEE)——当加载图表的时候出现错误No features contain non-null values of “system:time_start“.
124 0
|
4月前
|
人工智能 自然语言处理 数据挖掘
详解:Google AI Gemini中文版本(基于API 开发实现对话)
谷歌旗下的人工智能应用Gemini,自问世以来凭借其强大的计算能力和高效的处理性能,迅速成为全球用户的宠儿。作为一款由世界顶尖科技公司开发的产品,Gemini不仅在语言处理、图像识别、数据分析等领域表现出色,还在多种复杂任务中展现了其卓越的智能决策能力。然而,由于网络限制等问题,国内用户往往无法直接访问和使用Gemini的网站,这也导致了许多技术爱好者和专业人士未能亲身体验这一先进技术所带来的便利和强大功能。
|
5月前
|
域名解析 JavaScript 网络协议
技术心得记录:如何使用google地图的api(整理)
技术心得记录:如何使用google地图的api(整理)
451 0
|
6月前
|
API
Google Earth Engine(GEE)——加载的图表图例无法
Google Earth Engine(GEE)——加载的图表图例无法
33 0
|
6月前
Google Earth Engine——ndwi水体面积计算(landsat4/5/8)出现的无法加载影像的问题
Google Earth Engine——ndwi水体面积计算(landsat4/5/8)出现的无法加载影像的问题
43 0
|
6月前
Google Earth Engine APP(GEE)—— 一个简单的加载影像的UI(RGB,NDWI和NDVI)这里使用时间滑块进行时间选择
Google Earth Engine APP(GEE)—— 一个简单的加载影像的UI(RGB,NDWI和NDVI)这里使用时间滑块进行时间选择
105 0
|
6月前
|
JSON 搜索推荐 API
【2024更新】如何使用google index api来自动提交url
本文提供了一个详细的指南,说明如何创建并使用使用google index api,google自动提交url来优化seo。
|
6月前
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
2539 1
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
6月前
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
91 0