4

我试图在鸟瞰视图中找到地图角落的纬度和经度。我希望能够在地图上绘制图钉,但我有数十万个地址,我希望能够将其限制为需要在地图上显示的地址。

在普通视图中,VEMap.GetMapView().TopLeftLatLong 和 .BottomRightLatLong 返回我需要的坐标;但在 Birdseye 视图中,它们返回空白(或加密值)。SDK 建议使用 VEBirdseyeScene.GetBoundingRectangle(),但这会返回距离我的场景中心最多两英里的边界,在主要城市仍然返回太多地址。

在以前版本的 VE 控件中,有一个未记录的 VEDecoder 对象,我可以使用它来解密鸟瞰场景的 LatLong 值,但该对象似乎已经消失(可能已重命名)。如何在 6.1 版中解码这些值?

4

5 回答 5

3

在我看来,这个问题的示例解决方案总是只找到屏幕上当前地图的中心,就好像它总是你要点击的地方一样!无论如何,我编写了这个小函数来获取您在屏幕上单击的实际像素位置并为此返回一个 VELatLong。到目前为止,它似乎相当准确(尽管我认为这是一个巨大的、可怕的黑客攻击——但目前我们没有选择)。

它需要一个 VEPixel 作为输入,它是您在地图上单击的位置的 x 和 y 坐标。在传递给地图的 onclick 处理程序的鼠标事件上,您可以很容易地做到这一点。

function getBirdseyeViewLatLong(vePixel)
{
    var be = map.GetBirdseyeScene();

    var centrePixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

    var currentPixelWidth = be.GetWidth();
    var currentPixelHeight = be.GetHeight();

    var mapDiv = document.getElementById("map");
    var mapDivPixelWidth = mapDiv.offsetWidth;
    var mapDivPixelHeight = mapDiv.offsetHeight;

    var xScreenPixel = centrePixel.x - (mapDivPixelWidth / 2) + vePixel.x;
    var yScreenPixel = centrePixel.y - (mapDivPixelHeight / 2) + vePixel.y;

    var position = be.PixelToLatLong(new VEPixel(xScreenPixel, yScreenPixel), map.GetZoomLevel())
    return (new _xy1).Decode(position);
}
于 2009-05-13T20:19:03.353 回答
2

从 VEMap.GetCenter 方法文档:

当地图样式设置为 VEMapStyle.Birdseye 或 VEMapStyle.BirdseyeHybrid 时,此方法返回 null。

不过,这是我发现的:

var northWestLL = (new _xy1).Decode(map.GetMapView().TopLeftLatLong);
var southEastLL = (new _xy1).Decode(map.GetMapView().BottomRightLatLong);

(new _xy1) 似乎与旧的未记录的 VEDecoder 对象一样工作。

于 2008-09-02T16:37:07.390 回答
2

这是获取地图中心纬度/经度点的代码。此方法适用于 Road/Aerial 和 Birdseye/Oblique 地图样式。

function GetCenterLatLong()
        {
            //Check if in Birdseye or Oblique Map Style
            if (map.GetMapStyle() == VEMapStyle.Birdseye || map.GetMapStyle() == VEMapStyle.BirdseyeHybrid)
            {
                //IN Birdseye or Oblique Map Style


                //Get the BirdseyeScene being displayed
                var birdseyeScene = map.GetBirdseyeScene();


                //Get approximate center coordinate of the map
                var x = birdseyeScene.GetWidth() / 2;
                var y = birdseyeScene.GetHeight() / 2;

                // Get the Lat/Long 
                var center = birdseyeScene.PixelToLatLong(new VEPixel(x,y), map.GetZoomLevel());

                // Convert the BirdseyeScene LatLong to a normal LatLong we can use
                return (new _xy1).Decode(center);
            }
            else
            {
                // NOT in Birdseye or Oblique Map Style
                return map.GetCenter();
            }
        } 

此代码从此处复制:http: //pietschsoft.com/post/2008/06/Virtual-Earth-Get-Center-LatLong-When-In-Birdseye-or-Oblique-Map-Style.aspx

于 2008-09-15T21:44:18.257 回答
0

根据http://dev.live.com/virtualearth/sdk/这应该可以解决问题:

function GetInfo()         
{
  alert('The latitude,longitude at the center of the map is: '+map.GetCenter());         
}
于 2008-08-28T19:52:37.583 回答
0

Bing Maps 使用条款中的一个有趣点.. http://www.microsoft.com/maps/product/terms.html

鸟瞰航拍图像的使用限制:您不得透露纬度、经度、高度或其他元数据;

于 2009-07-07T00:46:39.110 回答