关于html:在Bing贴图多边形内显示标记

Displaying markers within a Bing maps Polygon

我正在使用Bing地图在地图上显示标记。

现在,我添加了一项功能,允许用户在自己选择的任何标记周围画一个圆,并让他以公里为单位指定圆的半径。

我希望圆(多边形)包含该圆的纬度/经度范围内的标记,而圆之外的标记消失。

我该如何实现?


您未提供代码。

但是,我参与了一个类似的项目,所以我对您正在谈论的内容有所了解。
因为您要查找自定义多边形,所以可以查看此链接。

另一种方法是使用标记的x,y坐标,并使用Javascript在地图上绘制一个圆。

该JAVASCRIPT应该有所帮助

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function drawCircle(radius, origin) {
    var RadPerDeg = Math.PI / 180;
    var earthRadius = 3959;  
    var lat = origin.latitude * RadPerDeg;
    var lon = origin.longitude * RadPerDeg;
    var locs = new Array();
    var AngDist = parseFloat(radius) / earthRadius;
    for (x = 0; x <= 360; x++) { //making a 360-sided polygon
        var pLatitude, pLongitude;
        // With a nice, flat earth we could just say p2.Longitude = lon * sin(brng) and p2.Latitude = lat * cos(brng)
        // But it ain't, so we can't.  See http://www.movable-type.co.uk/scripts/latlong.html
        brng = x * RadPerDeg;
        pLatitude = Math.asin(Math.sin(lat) * Math.cos(AngDist) + Math.cos(lat) * Math.sin(AngDist) * Math.cos(brng)); //still in radians
        pLongitude = lon + Math.atan2(Math.sin(brng) * Math.sin(AngDist) * Math.cos(lat), Math.cos(AngDist) - Math.sin(lat) * Math.sin(pLatitude));
        pLatitude = pLatitude / RadPerDeg;
        pLongitude = pLongitude / RadPerDeg;
        locs.push(new MM.Location(pLatitude, pLongitude));
    };
    circle = new MM.Polyline(locs, { visible: true, strokeThickness: 2, strokeDashArray:"1", strokeColor: new MM.Color(200, 0, 0, 200, 0) });
    map.entities.push(circle);
};