我有一张地图,用于填充数据库中的图钉。还有一个圆圈。我希望能够找出VE Shape圆圈半径内的其他图钉,并创建一个地址列表。
function addPushPin(lat, long) {
//var point = new Microsoft.Maps.Point(e.getX(), e.getY());
//var pushpinLocation = new(lat, long);
var s = new VEShape(VEShapeType.Pushpin, new VELatLong(lat,long));
var customIcon = new VECustomIconSpecification();
//customIcon.TextContent = "yo bana4na4";
customIcon.Image = "http://universidadescancun.com/wp-content/themes/GeoUnis3/images/pinpoint-fiesta.png";
//customIcon.ImageOffset = new VEPixel();
s.SetTitle("First Pin <span style=color:red>Demo Title<>/span>");
s.SetDescription("This comes to the <b>description</b> of pushpin.");
s.SetMoreInfoURL("http://dotnetricks.blogspot.com");
s.SetPhotoURL("http://upload.wikimedia.org/wikipedia/commons/8/8a/Banana-Single.jpg");
s.SetCustomIcon(customIcon);
s.SetIconAnchor(new VELatLong(lat, long));
map.AddShape(s);
}
我的地图也围绕其中一个图钉填充了一个圆圈。它就是这样填充的。
function getCircleNow(lat, long) {
var latin = lat;
var lonin = long;
var latlong = new VELatLong(latin, lonin);
centerPoint = (latlong);
//var center = map.GetCenter().toString();
//alert(center);
//Get initial circle points
var circlePoints = buildCircle(centerPoint.Latitude, centerPoint.Longitude, 50.74);
//Build circle
circle = new VEShape(VEShapeType.Polygon, circlePoints);
circle.HideIcon();
circle.SetLineWidth(2);
map.AddShape(circle);
//Build mask
circleMask = new VEShape(VEShapeType.Polygon, circlePoints);
circleMask.HideIcon();
circleMask.Hide();
circleMask.SetLineColor(new VEColor(0, 0, 0, 0.5));
circleMask.SetFillColor(new VEColor(0, 0, 0, 0.0));
circleMask.Primitives[0].symbol.stroke_dashstyle = "Dash";
map.AddShape(circleMask);
}
这是它调用的buildCircle()函数。
function buildCircle(latin, lonin, radius) {
var locs = new Array();
var lat1 = latin * Math.PI / 180.0;
var lon1 = lonin * Math.PI / 180.0;
var d = radius / 3956;
var x;
for (x = 0; x <= 360; x += 10) {
var tc = (x / 90) * Math.PI / 2;
var lat = Math.asin(Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(tc));
lat = 180.0 * lat / Math.PI;
var lon;
if (Math.cos(lat1) == 0) {
lon = lonin; // endpoint a pole
}
else {
lon = ((lon1 - Math.asin(Math.sin(tc) * Math.sin(d) / Math.cos(lat1)) + Math.PI) % (2 * Math.PI)) - Math.PI;
}
lon = 180.0 * lon / Math.PI;
var loc = new VELatLong(lat, lon);
locs.push(loc);
}
return locs;
}
这是我添加图钉后我的地图的样子,我在地图上填充了圆圈,它围绕其中一个位置并且半径为50英里。
我想做什么
我希望能够使用JavaScript或C#来检测除圆心所在的其他图钉之外的其他图钉是否在中心位置的半径范围内。或者更简单地说,圆圈中的其他位置/图钉是什么,并使用每个地址的值填充列表。我想不出任何可以做到这一点的特殊方法,所以任何帮助都会受到赞赏。这是我正在使用的Bing地图。
答案 0 :(得分:1)
这很容易做到。取中心点和圆的半径执行以下操作:
就是这样。很久以前,我还为Bing地图v6写了一篇MSDN文章,但看起来它已经脱机了,还有Bing地图v6.3的所有文档。
所有这些都说明了,值得指出的是Bing Maps V6.3真的很老了,最近更新了大约5或6年前。不建议对它进行任何新的开发,而是使用版本7,它更强大,功能更多,并且在下载大小方面明显更小。我在这里有一个迁移指南:http://social.technet.microsoft.com/wiki/contents/articles/20958.migrating-bing-maps-v6-3-to-v7.aspx