如何从地图Api网络服务中除印度以外的地图中删除其他国家..对这一挑战的任何想法..? [英] How to remove other country from map except India in map Api web service..Any idea about this challenge..?

查看:79
本文介绍了如何从地图Api网络服务中除印度以外的地图中删除其他国家..对这一挑战的任何想法..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿天才我对你有挑战

我想在静态地图虚构中显示印度的地图(For Bing Map Api)

这是你理解的链接

http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes? mapSize = 700600&安培; wp.0 =新德里,印度; 64; 1安培; WP.1 =斋浦尔,印度拉贾斯坦邦; 64; 2及WP.2 =阿格拉,UTT AR%20Pradesh,印度; 64; 3及WP.3 =占西,%20Madhya%20Pradesh,印度; 64; 4&安培; WP.4 =奥尔恰,中央%20Pradesh,印度; 64; 5&安培; WP.5 =克久拉霍,中央%20Pradesh,印度; 64; 6&安培; WP.6 =瓦拉纳西,北方邦%20Pradesh,印度; 64; 7&安培; WP.7 = Kolkata,西%20Bengal,印度; 64; 8&安培; WP.8 =奈,泰米尔语%20Nadu ,印度; 64; 9&安培; WP.9 =普兰,TAMILNADU,印度; 64; 10&安培; WP.10 =在Kanchipuram,TAMILNADU,印度; 64; 11&安培; WP.11 =马杜赖,TAMILNADU,印度; 64; 12&安培;键= AsgtkL4EokKmLiZdxC0XSzju3l5eWKCG8t5F9gzg8BuOLh91Py3u-e6PzrHRxwB8 [ ^ ]

在这里我只想显示印度而不是其他国家..所以任何人都有这个想法然后请告诉我....

解决方案

API本身不提供此功能,但有一种解决方法:



- 获取国家边界的坐标。您可以从 http://www.gadm.org/ 下载坐标[ ^ ]

- 将它们放入PointF数组中

 PointF [] selectedArea = {
new PointF( 1 .12345f, 3 .45678f),
...
}



- 翻译中的坐标数组到可见图块上的点,这将给你一个Point []。我不太了解这一部分,但此页 [ ^ ]有一个关于像素坐标的部分,显示确切的代码行从坐标转换为像素。我把它贴在这里作为参考(在VB中):

 sinLatitude = sin(纬度* pi / 180)
pixelX =((经度+ 180 )/ 360 )* 256 *(2 ^等级)
pixelY =( 0 5 - log(( 1 + sinLatitude)/( 1 - sinLatitude))/( 4 * pi))* 256 *(2 ^ level)



- 使用这些点创建多边形路径

 GraphicsPath polygonPath =  new  GraphicsPath(); 
polygonPath.AddPolygon(points);



- 为整个图块创建一个区域,如下所示(图块大小取决于详细程度,那里是上面链接中的表格,用于不同缩放级别的图块大小

区域区域=  Region( new 矩形( 0  0  256  256 )); 



- 排除刚刚创建的区域。

 region.Exclude(polygonPath); 



- 填写区域这将掩盖国界以外的一切

 graphics.FillRegion(Brushes.Black,region); 



为了使它看起来更漂亮,您可以决定使用点数组绘制一条线以清楚地标记国家边界。

 graphics.DrawLines(
new System.Drawing.Pen(System.Drawing.Color.FromArgb( 255 255 0 0 ), 3 ),
分);


hey genius I have a challenge for you
I want to show only India's map in static map imaginary(For Bing Map Api)
this is link for your understanding
http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?mapSize=700,600&wp.0=Delhi,India;64;1&wp.1=Jaipur,Rajasthan,India;64;2&wp.2=Agra,Uttar%20Pradesh,India;64;3&wp.3=Jhansi,%20Madhya%20Pradesh,India;64;4&wp.4=Orchha,Madhya%20Pradesh,India;64;5&wp.5=Khajuraho,Madhya%20Pradesh,India;64;6&wp.6=Varanasi,Uttar%20Pradesh,India;64;7&wp.7=Kolkata,West%20Bengal,India;64;8&wp.8=Chennai,Tamil%20Nadu,India;64;9&wp.9=Mahabalipuram,TamilNadu,India;64;10&wp.10=Kanchipuram,TamilNadu,India;64;11&wp.11=Madurai,TamilNadu,India;64;12&key=AsgtkL4EokKmLiZdxC0XSzju3l5eWKCG8t5F9gzg8BuOLh91Py3u-e6PzrHRxwB8[^]
In this I only want to display India not other country..so any one have idea about this then please tell me....

解决方案

The API itself doesn't offer this functionality, however there is a workaround:

- Get the coordinates for the country border. You can download the coordinates from http://www.gadm.org/[^]
- Put them in a PointF array

PointF[] selectedArea = {
  new PointF(1.12345f, 3.45678f),
  ...
}


- Translate the coordinates in the array to points on your visible tile, this will give you a Point[]. I don't know that part by hard, but this page[^] has a section on Pixel Coordinates showing you the exact lines of code to translate from coordinates to pixels. I paste it here for reference (in VB):

sinLatitude = sin(latitude * pi/180)
pixelX = ((longitude + 180) / 360) * 256 * (2^level)
pixelY = (0.5 – log((1 + sinLatitude) / (1 – sinLatitude)) / (4 * pi)) * 256 * (2^level)


- Create a polygon path using these points

GraphicsPath polygonPath = new GraphicsPath();
polygonPath.AddPolygon(points);


- Create a region for the entire tile, something like this (the tile size depends on the level of detail, there is a table in the link above for tile sizes for different 'zoom levels'

Region region = new Region(new Rectangle(0, 0, 256, 256));


- Exclude the area you just created.

region.Exclude(polygonPath);


- Fill the region with a color. This will mask out everything outside the country borders

graphics.FillRegion(Brushes.Black, region);


To make it look nicer, you may decide to draw a line using the points array to clearly mark the country border.

graphics.DrawLines(
new System.Drawing.Pen(System.Drawing.Color.FromArgb(255, 255, 0, 0), 3),
points);


这篇关于如何从地图Api网络服务中除印度以外的地图中删除其他国家..对这一挑战的任何想法..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆