ArcGIS API for Silverlight 加载google地图

简介: 原文:ArcGIS API for Silverlight 加载google地图  using System; using System.Net; using System.Windows; using System.
原文: ArcGIS API for Silverlight 加载google地图

 

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>

目录
相关文章
|
28天前
|
人工智能 Java API
Google Gemini API 接口调用方法
Google 最近发布的 Gemini 1.0 AI 模型通过其升级版,Gemini,标志着公司迄今为止最为强大和多功能的人工智能技术的突破。
|
8月前
|
人工智能 NoSQL 定位技术
标准地图的矢量模板,ArcGIS可打开
标准地图的矢量模板,ArcGIS可打开
101 0
|
28天前
|
定位技术 API
Google Earth Engine(GEE)——如何给地图添加一个不同底图
Google Earth Engine(GEE)——如何给地图添加一个不同底图
59 0
|
28天前
|
机器学习/深度学习 编解码 人工智能
Google Earth Engine(GEE)——2019年数字地球非洲的耕地范围地图
Google Earth Engine(GEE)——2019年数字地球非洲的耕地范围地图
24 0
|
28天前
|
数据可视化 定位技术 API
Google Earth Engine(GEE) ——土著土地地图数据集
Google Earth Engine(GEE) ——土著土地地图数据集
25 1
|
28天前
|
JSON 搜索推荐 API
【2024更新】如何使用google index api来自动提交url
本文提供了一个详细的指南,说明如何创建并使用使用google index api,google自动提交url来优化seo。
63 0
|
11月前
|
定位技术
ArcGIS:地图单位和视图单位(显示单位)的区别?
ArcGIS:地图单位和视图单位(显示单位)的区别?
115 0
|
28天前
|
人工智能 编解码 定位技术
ArcGIS导出AI或EPS格式的地图图片并在Adobe Illustrator中继续编辑
ArcGIS导出AI或EPS格式的地图图片并在Adobe Illustrator中继续编辑
132 1
|
28天前
|
存储 定位技术
ArcGIS中ArcMap导入mxd地图文档文件出现红色感叹号、地图空白的解决
ArcGIS中ArcMap导入mxd地图文档文件出现红色感叹号、地图空白的解决
|
28天前
|
编解码 定位技术 Python
Python中ArcPy实现ArcGIS自动批量制图与地图要素批量设置
Python中ArcPy实现ArcGIS自动批量制图与地图要素批量设置