原文:ArcGIS API for Silverlight 加载google地图

ArcGIS API for Silverlight 加载google地图-LMLPHP

ArcGIS API for Silverlight 加载google地图-LMLPHP

ArcGIS API for Silverlight 加载google地图-LMLPHP

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>
05-02 07:18