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);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。