arcgis 中引入bingmap
来源:互联网 发布:mysql 修改复合主键 编辑:程序博客网 时间:2024/05/18 22:43
前期:有KEY码。。。通过注册获取
(1)加入bingmap,因为是3857坐标系统。Spatial Reference: 102100 (3857)
102100 WGS_1984_Web_Mercator_Auxiliary_Sphere 。
所以要作为最底图加入即可
(2)叠加tile的类:
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using System.Windows;
using System;
namespace Diligentpig
{
public class ClientDynamicTileMapServiceLayer : TiledMapServiceLayer
{
public bool iscansee = true;
public static readonly DependencyProperty UrlProperty = DependencyProperty.Register("Url", typeof(string), typeof(ClientDynamicTileMapServiceLayer), new PropertyMetadata(new PropertyChangedCallback(ClientDynamicTileMapServiceLayer.OnUrlPropertyChanged)));
public string Url
{
get { return (string)GetValue(UrlProperty); }
set { SetValue(UrlProperty, value); }
}
public static readonly DependencyProperty DisableClientCacheProperty = DependencyProperty.Register("DisableClientCache", typeof(bool), typeof(ClientDynamicTileMapServiceLayer), new PropertyMetadata(new PropertyChangedCallback(ClientDynamicTileMapServiceLayer.OnDisableClientCachePropertyChanged)));
public bool DisableClientCache
{
get { return (bool)GetValue(DisableClientCacheProperty); }
set { SetValue(DisableClientCacheProperty, value); }
}
private int[] _visibleLayers;
/// <summary>
/// Set the visible layers of DynamicTileMapServiceLayer by an int array which starts from 0.
/// If sets to NULL, all sublayers will be visible.
/// </summary>
public int[] VisibleLayers
{
get { return _visibleLayers; }
set
{
_visibleLayers = value;
if (this.IsInitialized)
{
this.IsInitialized = false;
this.InitializationFailure = null;
this.Refresh();
this.Initialize();
}
}
}
private const double cornerCoordinate = 20037508.3427892;
public override void 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)
{
if (iscansee)
{
string baseUrl = @"{0}/export?udpi=96&transparent=true&format=png8&bbox={1}%2C{2}%2C{3}%2C{4}&bboxSR=102100&imageSR=102100&size=256%2C256&f=image";
double cornerCoordinate = 20037508.3427892;//from wkid 3857/102100
double originResolution = cornerCoordinate * 2 / 256;
double resolution = originResolution;
for (int i = 0; i < level; i++)
{
resolution /= 2;
}
double xmin, ymin, xmax, ymax;
//double resolution = 39135.7584820001;
xmin = -cornerCoordinate + resolution * 256 * col;
ymin = cornerCoordinate - resolution * 256 * (row + 1);
xmax = -cornerCoordinate + resolution * 256 * (col + 1);
ymax = cornerCoordinate - resolution * 256 * row;
//string[] subServices = { "stgeometry", "stgeometry1", "stgeometry2" };
//string baseUrl = @"http://192.168.200.231:8399/arcgis/rest/services/{0}/MapServer/export?dpi=96&transparent=true&format=png8&bbox={1}%2C{2}%2C{3}%2C{4}&bboxSR=102100&imageSR=102100&size=256%2C256&f=image&_ts={5}";
//string subservice = subServices[(level + col + row) % subServices.Length];
//return string.Format(baseUrl, subservice, xmin, ymin, xmax, ymax, DateTime.Now.Ticks.ToString());
if (VisibleLayers != null)//if null, all sublayers are visible.
{
//ex. layers=show:2,4,7
string str = "&layers=show:";
for (int i = 0; i < VisibleLayers.Length; i++)
{
str = str.Insert(str.Length, VisibleLayers[i].ToString() + ",");
};
str = str.Remove(str.Length - 1);//remove last ","
baseUrl = baseUrl.Insert(baseUrl.Length, str);
}
if (DisableClientCache)
{
baseUrl = baseUrl.Insert(baseUrl.Length, "&_ts={5}");
return string.Format(baseUrl, Url, xmin, ymin, xmax, ymax, DateTime.Now.Ticks.ToString());
}
return string.Format(baseUrl, Url, xmin, ymin, xmax, ymax);
}
else return "";
}
private static void OnUrlPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
try
{
ClientDynamicTileMapServiceLayer layer = (ClientDynamicTileMapServiceLayer)d;
if (layer.IsInitialized)
{
layer.IsInitialized = false;
layer.InitializationFailure = null;
layer.Refresh();
layer.Initialize();
}
}
catch (Exception ex)
{
MessageBox.Show("ArcGISDynamicMapServiceLayer Url is invalid!/n" + ex.Message);
};
}
private static void OnDisableClientCachePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ClientDynamicTileMapServiceLayer layer = (ClientDynamicTileMapServiceLayer)d;
if (layer.IsInitialized)
{
layer.IsInitialized = false;
layer.InitializationFailure = null;
layer.Refresh();
layer.Initialize();
}
}
}
}
(3)增加坐标转化系统:
//经纬度转墨卡托
public static Point lonLat2Mercator(Point lonLat)
{
if (type<= 1)
{
double x = lonLat.X * 20037508.34 / 180;
double M_PI = Math.PI;
double y = Math.Log(Math.Tan((90 + lonLat.Y) * M_PI / 360)) / (M_PI / 180);
y = y * 20037508.34 / 180;
Point mercator = new Point(x, y);
return mercator;
}
else
{
Point mercator = lonLat;
return mercator;
}
}
//墨卡托转经纬度
public static Point Mercator2lonLat(Point mercator)
{
if (type<= 1)
{
double x = mercator.X / 20037508.34 * 180;
double y = mercator.Y / 20037508.34 * 180;
double M_PI = Math.PI;
y = 180 / M_PI * (2 * Math.Atan(Math.Exp(y * M_PI / 180)) - M_PI / 2);
Point lonLat = new Point(x, y);
return lonLat;
}
else
{
Point lonLat=mercator;
return lonLat;
}
}
//================示例如下==========================
ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = feature.Geometry.Extent;
double expandPercentage = 100;
double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 10);
if (widthExpand == 0) widthExpand = 0.6;
double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 10);
if (heightExpand == 0) heightExpand = 0.6;
Point p1 = new Point(selectedFeatureExtent.XMin - (widthExpand / 2),
selectedFeatureExtent.YMin - (heightExpand / 2));
Point pM1 = ToolConvert.lonLat2Mercator(p1);
Point p2 = new Point(selectedFeatureExtent.XMax + (widthExpand / 2),
selectedFeatureExtent.YMax + (heightExpand / 2));
Point pM2 = ToolConvert.lonLat2Mercator(p2);
ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
pM1.X,pM1.Y,
pM2.X, pM2.Y);
mp.MyMap.ZoomTo(displayExtent);
- arcgis 中引入bingmap
- 在ArcGIS 10 Desktop中打开Google Map,BingMap
- BingMap
- ArcGIS for Android示例解析之添加bingMap-----AddBingMap
- ArcGIS API for Silverlight加载BingMap遥感地图
- bingmap中添加traffic和incident
- BingMap事件中this的使用
- bingmap中隐藏bing(logo)的问题
- ArcGIS API for Silverlight 加载BingMap,GoogleMap,WorldImageryMap,OpenStreetMap,BaiduMap方法
- 关于在ArcGIS WebAppBuilder的widget开发中引入EasyUI的一些方法
- BingMap读取shape(arcgis)格式数据(将shape文件转成Sql server2008的geometry类型,再进行读取)
- bingmap ajax v7.0中实现v6.3中的find功能
- BingMap中两个地图引发的问题(route和Automatic)
- ArcGIS API for Silverlight 使用GoogleMap,BingMap等作为地图地图时应注意的坐标系问题————Web Mercator
- bingmap瓦片数据下载
- BingMap地图显示中文
- bingMap的使用小结
- MyEclipse中引入中文包
- EntityFramework 4.0 中添加对存储过程的调用
- 中断代码结构比较之WinCE4.2 VS WinCE5.0
- struts 标签简介
- jsp页面equal symbol expected错误
- 中断使能、禁止程序——之oem.c程序分析
- arcgis 中引入bingmap
- 区分Activity的四种加载模式
- 交通灯管理系统
- hdoj1010 Tempter of the Bone(深度优先搜索)
- 生活
- C语言文件操作函数大串讲
- jstl和EL表达式不起作用的问题
- 请问Eclipse中源码的中文部分都显示成乱码如何解决
- 银行业务调度系统