SharpGIS博客翻译2006年9月:在local live地图上叠加自己的数据
2007-03-28 20:59
591 查看
Overlaying Local Live maps with your own map-data [原文] [翻译] [作者:心帆]
原文:
Recently the Virtual Earth team released a new version of their API . One of the new features allowed to overlay the maps with tiles from your own tile-server. The tile-server can be added using a few lines of javascript like this:
var tileSourceSpec = new VETileSourceSpecification();
tileSourceSpec.ID = "POPDENS" ;
tileSourceSpec.GetTilePath = GetTilePath;
tileSourceSpec.NumServers = 1;
tileSourceSpec.MinZoom = 1;
tileSourceSpec.MaxZoom = 16;
vemap.AddTileSource(tileSourceSpec);
var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"POPDENS", "POPDENS");
tileLayer.Opacity=0.6;
vemap.AddLayer(tileLayer);
This will add a new tile layer named "POPDENS" to the virtual earth map, and make it slightly transparent. The GetTilePath parameter refers to the JavaScript method that creates the request-url to the server. Ex:
function GetTilePath (tileContext) {
if (tileContext != null && tileContext != "undefined" ) {
return "VEmap.ashx?WIDTH=256&HEIGHT=256&X=" + tileContext.XPos + "&Y=" + tileContext.YPos + "&ZoomLevel=" + tileContext.ZoomLevel;
}
}
The X, Y and ZoomLevel parameters in this querystring are unfortunately not simple coordinates, but are the row/column of the tile at the current zoom level. Rob Blackwell has earlier posted an article on how to convert these to longitude/latitude values.
The next step is to create the tile-server. I used SharpMap for this. SharpMap's on-the-fly transformation capability is needed to transform the data to the Mercator projection that Virtual Earth uses, but any map-renderer that can project data could be used. You could also create a javascript that makes the GetTilePath method return a WMS request instead and then use any of the many WMS servers available.
The basic trick is to use Rob Blackwell's methods for calculating the longitude/latitude of each tile's corners, transform these coordinates to the Mercator projection and render the resulting extent.
You can view a small demo of a Population Density map overlaying the Virtual Earth map here: http://showcase.sharpgis.net/ve/
...or you can download the full source: VirtualEarth.zip (389,09 KB)
You can easily add your own data by editing the CreateMap method in /App_Code/Map.cs
译文:
最近Virtual Earth项目组发布了新版本的API . 有一个新特性就是可以在你的tile-server上叠加地图。参照使用以下javascript代码:
var tileSourceSpec = new VETileSourceSpecification();
tileSourceSpec.ID = "POPDENS" ;
tileSourceSpec.GetTilePath = GetTilePath;
tileSourceSpec.NumServers = 1;
tileSourceSpec.MinZoom = 1;
tileSourceSpec.MaxZoom = 16;
vemap.AddTileSource(tileSourceSpec);
var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"POPDENS", "POPDENS");
tileLayer.Opacity=0.6;
vemap.AddLayer(tileLayer);
以上将添加一个新的名称为"POPDENS"图层到virtual earth 地图,并使它有透明的效果。GetFilePath参数是JavaScript的方法,用来创建的服务器URL,例如:
function GetTilePath (tileContext) {
if (tileContext != null && tileContext != "undefined" ) {
return "VEmap.ashx?WIDTH=256&HEIGHT=256&X=" + tileContext.XPos + "&Y=" + tileContext.YPos + "&ZoomLevel=" + tileContext.ZoomLevel;
}
}
在这个请求中,X, Y 和 ZoomLevel参数不是简单的坐标,而是当然缩放比例下tile的行/列值。 Rob Blackwell 早些时候 有一篇文章 讲述如何将它们转换成经纬度值。
下一步是创建tile-server。我使用 SharpMap 。Virtual Earth使用的是 Mercator(麦卡托)投影, SharpMap可以使用任何投影的数据,但必须转化为Mercator投影才能够创建tile-server。你也可以写一个javascript的GetTilePath函数返回一个WMS请求,这样可以使用许多WMS服务器的数据。
The basic trick is to use Rob Blackwell's methods for calculating the longitude/latitude of each tile's corners, transform these coordinates to the Mercator projection and render the resulting extent.
最基本的技巧是需要使用Rob Blackwell的方法来计算每一个tile四个角上的经纬度,将这些坐标转化为Mercator坐标然后这个范围内的地图。
下面是一个简单的将人口密度图叠加到Virtual Earth 上的示例: http://showcase.sharpgis.net/ve/
源码: VirtualEarth.zip (389,09 KB)
修改/App_Code/Map.cs文件中的CreateMap函数,可以很容易的加入自己的数据。
译注:
tile:原意是瓦片, 瓷砖,此文中应该是指整个地图是由一块一块拼起来的,tile指其中的一块。
tile-sever:应该是指能提供由块状地图拼接地图的服务器,例如google maps等等。
不知道以上理解是否正确,更不知道如何翻译成中文。
原文:
Recently the Virtual Earth team released a new version of their API . One of the new features allowed to overlay the maps with tiles from your own tile-server. The tile-server can be added using a few lines of javascript like this:
var tileSourceSpec = new VETileSourceSpecification();
tileSourceSpec.ID = "POPDENS" ;
tileSourceSpec.GetTilePath = GetTilePath;
tileSourceSpec.NumServers = 1;
tileSourceSpec.MinZoom = 1;
tileSourceSpec.MaxZoom = 16;
vemap.AddTileSource(tileSourceSpec);
var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"POPDENS", "POPDENS");
tileLayer.Opacity=0.6;
vemap.AddLayer(tileLayer);
This will add a new tile layer named "POPDENS" to the virtual earth map, and make it slightly transparent. The GetTilePath parameter refers to the JavaScript method that creates the request-url to the server. Ex:
function GetTilePath (tileContext) {
if (tileContext != null && tileContext != "undefined" ) {
return "VEmap.ashx?WIDTH=256&HEIGHT=256&X=" + tileContext.XPos + "&Y=" + tileContext.YPos + "&ZoomLevel=" + tileContext.ZoomLevel;
}
}
The X, Y and ZoomLevel parameters in this querystring are unfortunately not simple coordinates, but are the row/column of the tile at the current zoom level. Rob Blackwell has earlier posted an article on how to convert these to longitude/latitude values.
The next step is to create the tile-server. I used SharpMap for this. SharpMap's on-the-fly transformation capability is needed to transform the data to the Mercator projection that Virtual Earth uses, but any map-renderer that can project data could be used. You could also create a javascript that makes the GetTilePath method return a WMS request instead and then use any of the many WMS servers available.
The basic trick is to use Rob Blackwell's methods for calculating the longitude/latitude of each tile's corners, transform these coordinates to the Mercator projection and render the resulting extent.
You can view a small demo of a Population Density map overlaying the Virtual Earth map here: http://showcase.sharpgis.net/ve/
...or you can download the full source: VirtualEarth.zip (389,09 KB)
You can easily add your own data by editing the CreateMap method in /App_Code/Map.cs
译文:
最近Virtual Earth项目组发布了新版本的API . 有一个新特性就是可以在你的tile-server上叠加地图。参照使用以下javascript代码:
var tileSourceSpec = new VETileSourceSpecification();
tileSourceSpec.ID = "POPDENS" ;
tileSourceSpec.GetTilePath = GetTilePath;
tileSourceSpec.NumServers = 1;
tileSourceSpec.MinZoom = 1;
tileSourceSpec.MaxZoom = 16;
vemap.AddTileSource(tileSourceSpec);
var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"POPDENS", "POPDENS");
tileLayer.Opacity=0.6;
vemap.AddLayer(tileLayer);
以上将添加一个新的名称为"POPDENS"图层到virtual earth 地图,并使它有透明的效果。GetFilePath参数是JavaScript的方法,用来创建的服务器URL,例如:
function GetTilePath (tileContext) {
if (tileContext != null && tileContext != "undefined" ) {
return "VEmap.ashx?WIDTH=256&HEIGHT=256&X=" + tileContext.XPos + "&Y=" + tileContext.YPos + "&ZoomLevel=" + tileContext.ZoomLevel;
}
}
在这个请求中,X, Y 和 ZoomLevel参数不是简单的坐标,而是当然缩放比例下tile的行/列值。 Rob Blackwell 早些时候 有一篇文章 讲述如何将它们转换成经纬度值。
下一步是创建tile-server。我使用 SharpMap 。Virtual Earth使用的是 Mercator(麦卡托)投影, SharpMap可以使用任何投影的数据,但必须转化为Mercator投影才能够创建tile-server。你也可以写一个javascript的GetTilePath函数返回一个WMS请求,这样可以使用许多WMS服务器的数据。
The basic trick is to use Rob Blackwell's methods for calculating the longitude/latitude of each tile's corners, transform these coordinates to the Mercator projection and render the resulting extent.
最基本的技巧是需要使用Rob Blackwell的方法来计算每一个tile四个角上的经纬度,将这些坐标转化为Mercator坐标然后这个范围内的地图。
下面是一个简单的将人口密度图叠加到Virtual Earth 上的示例: http://showcase.sharpgis.net/ve/
源码: VirtualEarth.zip (389,09 KB)
修改/App_Code/Map.cs文件中的CreateMap函数,可以很容易的加入自己的数据。
译注:
tile:原意是瓦片, 瓷砖,此文中应该是指整个地图是由一块一块拼起来的,tile指其中的一块。
tile-sever:应该是指能提供由块状地图拼接地图的服务器,例如google maps等等。
不知道以上理解是否正确,更不知道如何翻译成中文。
相关文章推荐
- SharpGIS博客翻译2006年9月:在local live地图上叠加自己的数据
- SharpGIS博客翻译2006年7月:使用XAML来渲染地图
- SharpGIS博客翻译2006年7月:使用XAML来渲染地图
- SharpGIS博客翻译2005年6月:使用.NET来渲染地图
- SharpGIS博客翻译2005年6月:使用.NET来渲染地图
- SharpGIS博客翻译2006年8月:微软SQL Server空间扩展模块工程
- SharpGIS博客翻译2006年7月:在SharpMap中增加饼图
- SharpGIS博客翻译2006年12月:ArcGIS Server项目团队博客
- SharpGIS博客翻译2006年11月:微软地球
- SharpGIS博客翻译:总结回顾及新活动开始倡议
- SharpGIS博客翻译2006年7月:在SharpMap中使用即时坐标变换
- SharpGIS博客翻译2006年5月:扩展微软 SQL Server 的空间功能
- SharpGIS博客翻译2006年8月:微软SQL Server空间扩展模块工程
- SharpGIS博客翻译2006年7月:在SharpMap中使用即时坐标变换
- SharpGIS博客翻译2006年11月:微软地球
- SharpGIS博客翻译2006年12月:ArcGIS Server项目团队博客
- SharpGIS博客翻译2006年5月:扩展微软 SQL Server 的空间功能
- SharpGIS博客翻译2006年7月:在SharpMap中增加饼图
- 设计自己的地图叠加到 Google Maps或者 MicroSoft Vitual Earth
- 制作自己博客的翻译工具