1

マップ上にマーカーを表示するために Bing マップを使用しています。

現在、ユーザーが選択した任意のマーカーの周りに円を描き、円の半径をキロメートルで指定できるようにする機能を追加しています。

円(ポリゴン)にその円の緯度/経度の境界内にマーカーを含め、円の外側のマーカーを非表示にしたい。

どうすればこれを達成できますか?

4

1 に答える 1

0

コードが提供されていません。

しかし、私は同様のプロジェクトに携わっていたので、あなたが何を話しているのか分かります. カスタム ポリゴンを探しているので、このリンクを参照してください。

それを行う別の方法は、マーカーの x、y 座標に、Javascript を使用してマップの周りに円を描くことです。

このジャバスクリプトが役立つはずです

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);
};
于 2013-07-19T08:09:04.133 に答える