
string baseUrl = "http://mt2.google.cn/vt/lyrs=s@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//卫星图
string cbaseUrl = "http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&x=0&y=0&z=0&s=Galil";//市区图
页面
<UserControl x:Class="SilverlightApplication6.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"
xmlns:open="clr-namespace:ESRI.ArcGIS.ClIEnt.Toolkit.DataSources;assembly=ESRI.ArcGIS.ClIEnt.Toolkit.DataSources"
xmlns:Classgoole="SilverlightApplication6"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWIDth="400" xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
<GrID x:name="LayoutRoot" Background="White">
<esri:Map Background="White" HorizontalAlignment="left" name="map1" VerticalAlignment="top" Height="300" WIDth="400">
</esri:Map>
</GrID>
</UserControl>
后台
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;
namespace SilverlightApplication6
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
map1.Loaded += LoadMap;
}
private voID LoadMap(object sender,RoutedEventArgs e)
{
GoogleMapLayer gm = new GoogleMapLayer();
map1.Layers.Add(gm);
}
}
}
GoogleMapLayer
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;
using ESRI.ArcGIS.ClIEnt;
using ESRI.ArcGIS.ClIEnt.Geometry;
public class GoogleMapLayer : TiledMapServiceLayer
{
private const double cornerCoordinate = 20037508.3427892;
public overrIDe voID Initialize()
{
//this.Opacity = 0.5;
this.FullExtent = new
ESRI.ArcGIS.ClIEnt.Geometry.Envelope(-20037508.342787,-20037508.342787,20037508.342787,20037508.342787);//(-180,-85.0511287798066,180,85.0511287798066)
{
SpatialReference = new ESRI.ArcGIS.ClIEnt.Geometry.SpatialReference(102100);
};
this.SpatialReference = new ESRI.ArcGIS.ClIEnt.Geometry.SpatialReference(102100);
//this.InitialExtent = this.FullExtent;
this.TileInfo = new TileInfo()
{
Height = 256,
WIDth = 256,
Origin = new ESRI.ArcGIS.ClIEnt.Geometry.MapPoint(-20037508.342787,20037508.342787)//Origin = new ESRI.ArcGIS.Geometry.MapPoint(-180,90)
{
SpatialReference = new ESRI.ArcGIS.ClIEnt.Geometry.SpatialReference(102100)
},
Lods = new Lod[20]
};
double resolution = 156543.033928;
for(int i = 0; i < TileInfo.Lods.Length; i++)
{
TileInfo.Lods[i] = new Lod() { Resolution = resolution };
resolution /= 2;
}
base.Initialize();
//this.FullExtent = new ESRI.ArcGIS.ClIEnt.Geometry.Envelope(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892)
//{
// SpatialReference = new SpatialReference(102100)
//};
//// This layer's spatial reference
//this.SpatialReference = new SpatialReference(102100);
//// Set up tile information. Each tile is 256x256px,19 levels.
//this.TileInfo = new TileInfo()
//{
// Height = 256,
// WIDth = 256,
// Origin = new MapPoint(-cornerCoordinate,cornerCoordinate) { SpatialReference = new ESRI.ArcGIS.ClIEnt.Geometry.SpatialReference(102100) },
// Lods = new Lod[19]
//};
//// Set the resolutions for each level. Each level is half the resolution of the prevIoUs one.
//double resolution = cornerCoordinate * 2 / 256;
//for (int i = 0; i < TileInfo.Lods.Length; i++)
//{
// TileInfo.Lods[i] = new Lod() { Resolution = resolution };
// resolution /= 2;
//}
//// Call base initialize to raise the initialization event
//base.Initialize();
}
public overrIDe string GetTileUrl(int level,int row,int col)
{
// int num = (col + (2 * row)) % 4;
// string str = "&s=";
// string str2 = "galileo";
// int length = ((col * 3) + row) % 8;
// str = str + str2.Substring(0,length);
// if (row >= 0x2710)
// {
// }
// string str3 = "http://khm" + num.ToString() + ".Google.com/kh=49&x=";
// return (str3 + col.ToString() + "&y=" + row.ToString() + "&z=" + level.ToString() + str);
string baseUrl = "http://mt2.google.cn/vt/lyrs=s@167000000&hl=zh-CN&gl=cn&s=Galil&x=";//卫星图
string cbaseUrl = "http://mt2.google.cn/vt/lyrs=m@167000000&hl=zh-CN&gl=cn&x=0&y=0&z=0&s=Galil";//市区图 string url = baseUrl + col.ToString() + "&y=" + row.ToString() + "&z=" + level.ToString() + ""; return url; } }
以上是内存溢出为你收集整理的silverlight 连接google map全部内容,希望文章能够帮你解决silverlight 连接google map所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)