1.地图图层 <esri:Map x:name="mymap" WrapAround="True" SnapTolevels="True" Extent="13026373.9205,4389217.2155,13039428.4582,4395595.7317" > <esri:Map.Layers > <GoogDitu:GoogletopographicLayer > </GoogDitu:GoogletopographicLayer> <esri:Graphicslayer ID="MyGraphicslayer"/> </esri:Map.Layers> </esri:Map> Extent表示地图的范围大小,数值是墨卡托数
2.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; using ESRI.ArcGIS.ClIEnt; using ESRI.ArcGIS.ClIEnt.Geometry; public class GoogletopographicLayer: TiledMapServiceLayer { private const double cornerCoordinate = 20037508.3427892; private string _baseURL = "m@161000000"; public overrIDe voID Initialize() { ESRI.ArcGIS.ClIEnt.Projection.WebMercator mercator = new ESRI.ArcGIS.ClIEnt.Projection.WebMercator(); this.FullExtent = new ESRI.ArcGIS.ClIEnt.Geometry.Envelope(-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892) { SpatialReference = new SpatialReference(102100) }; //图层的空间坐标系 this.SpatialReference = new SpatialReference(102100); // 建立切片信息,每个切片大小256*256px,共16级. this.TileInfo = new TileInfo() { Height = 256,WIDth = 256,Origin = new MapPoint(-cornerCoordinate,cornerCoordinate) { SpatialReference = new ESRI.ArcGIS.ClIEnt.Geometry.SpatialReference(102100) },Lods = new Lod[20] }; //为每级建立方案,每一级是前一级别的一半. double resolution = cornerCoordinate * 2 / 256; for (int i = 0; i < TileInfo.Lods.Length; i++) { TileInfo.Lods[i] = new Lod() { Resolution = resolution }; resolution /= 2; } // 调用初始化函数 base.Initialize(); } public overrIDe string GetTileUrl(int level,int row,int col) { string url = "http://mt" + (col % 4) + ".Google.cn/vt/lyrs=" + _baseURL + "&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=galil"; if (_baseURL == "s@92") { url = "http://mt" + (col % 4) + ".Google.cn/vt/lyrs=" + _baseURL + "&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=galil"; //加载Google遥感图 } if (_baseURL == "t@128") { url = "http://mt" + (col % 4) + ".Google.cn/vt/lyrs=" + _baseURL + ",r@169000000&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=galil";//加载Google地形图 } if (_baseURL == "m@161000000") { url = "http://mt" + (col % 4) + ".Google.cn/vt/lyrs=" + _baseURL + "&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&s=galil"; //加载Google街道图 } return string.Format(url); //调用加载初始的Google街道地图 //string baseUrl = "http://mt2.Google.cn/vt/v=w2.116&hl=zh-CN&gl=cn&x={0}&y={1}&z={2}&s=G"; //return string.Format(baseUrl,col,row,level); //以上显示的Google地图类型,有三种,根据需要,可以修改变量_baseURL的初始值即可。 } }
3.地图的放大缩小
mymap.Zoom(1.5)其中数值大于1是放大 mymap.Zoom(0.5)数值小于1是缩小
3.地图的中心点改变mymap.PanTo()这个方法里放的是墨卡托经纬度
4.改变地图点的图标 Symbol = new PictureMarkerSymbol() { Source = new BitmAPImage(new Uri("../Images/pr.png",UriKind.relative)),WIDth = 20,Height = 17 }
5.给地图添加图标 Graphicslayer graphicslayer = mymap.Layers["MyGraphicslayer"] as Graphicslayer; MyGraphic graphic = new MyGraphic() { Geometry = mercator.FromGeographic(new MapPoint(Convert.Todouble(item.Longitude),Convert.Todouble(item.Latitude))),Symbol = new PictureMarkerSymbol() { Source = new BitmAPImage(new Uri("../Images/pr.png",Height = 17 },}; graphicslayer.Graphics.Add(graphic);总结
以上是内存溢出为你收集整理的ArcGIS for Silverlight API google地图 *** 作全部内容,希望文章能够帮你解决ArcGIS for Silverlight API google地图 *** 作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)