如何在Virtual Earth中找到鸟瞰场景的确切纬度/经度坐标?

时间:2021-07-18 21:17:09

I'm trying to find the latitude and longitude of the corners of my map while in birdseye view. I want to be able to plot pins on the map, but I have hundreds of thousands of addresses that I want to be able to limit to the ones that need to show on the map.

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

In normal view, VEMap.GetMapView().TopLeftLatLong and .BottomRightLatLong return the coordinates I need; but in Birdseye view they return blank (or encrypted values). The SDK recommends using VEBirdseyeScene.GetBoundingRectangle(), but this returns bounds of up to two miles from the center of my scene which in major cities still returns way too many addresses.

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

In previous versions of the VE Control, there was an undocumented VEDecoder object I could use to decrypt the LatLong values for the birdseye scenes, but this object seems to have disappeared (probably been renamed). How can I decode these values in version 6.1?

在VE Con​​trol的早期版本中,有一个未记录的VEDecoder对象可用于解密鸟眼场景的LatLong值,但这个对象似乎已经消失(可能已经重命名)。如何在6.1版中解码这些值?

5 个解决方案

#1


2  

Here's the code for getting the Center Lat/Long point of the map. This method works in both Road/Aerial and Birdseye/Oblique map styles.

这是获取地图中心纬度/长点的代码。此方法适用于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();
            }
        } 

This code was copied from here: http://pietschsoft.com/post/2008/06/Virtual-Earth-Get-Center-LatLong-When-In-Birdseye-or-Oblique-Map-Style.aspx

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

#2


2  

It always seems to me that the example solutions for this issue only find the centre of the current map on the screen, as if that is always the place you're going to click! Anyway, I wrote this little function to get the actual pixel location that you clicked on the screen and return a VELatLong for that. So far it seems pretty accurate (even though I see this as one big, horrible hack - but it's not like we have a choice at the moment).

在我看来,这个问题的示例解决方案只能在屏幕上找到当前地图的中心,就好像这一直是你要点击的地方!无论如何,我写了这个小函数来获取你在屏幕上点击的实际像素位置并返回一个VELatLong。到目前为止它看起来非常准确(尽管我认为这是一个大而可怕的黑客 - 但它并不像我们现在有选择)。

It takes a VEPixel as input, which is the x and y coordinates of where you clicked on the map. You can get that easily enough on the mouse event passed to the onclick handler for the map.

它需要一个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);
}

#3


1  

From the VEMap.GetCenter Method documentation:

从VEMap.GetCenter方法文档:

This method returns null when the map style is set to VEMapStyle.Birdseye or VEMapStyle.BirdseyeHybrid.

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

Here is what I've found, though:

这是我发现的,但是:

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

The (new _xy1) seems to work the same as the old undocumented VEDecoder object.

(new _xy1)似乎与旧的未记录的VEDecoder对象相同。

#4


0  

An interesting point in the Bing Maps Terms of Use.. http://www.microsoft.com/maps/product/terms.html

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

Restriction on use of Bird’s eye aerial imagery: You may not reveal latitude, longitude, altitude or other metadata;

使用鸟瞰航空影像的限制:您可能无法显示纬度,经度,海拔高度或其他元数据;

#5


0  

According to http://dev.live.com/virtualearth/sdk/ this should do the trick:

根据http://dev.live.com/virtualearth/sdk/,这应该做的伎俩:

function GetInfo()         
{
  alert('The latitude,longitude at the center of the map is: '+map.GetCenter());         
}

#1


2  

Here's the code for getting the Center Lat/Long point of the map. This method works in both Road/Aerial and Birdseye/Oblique map styles.

这是获取地图中心纬度/长点的代码。此方法适用于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();
            }
        } 

This code was copied from here: http://pietschsoft.com/post/2008/06/Virtual-Earth-Get-Center-LatLong-When-In-Birdseye-or-Oblique-Map-Style.aspx

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

#2


2  

It always seems to me that the example solutions for this issue only find the centre of the current map on the screen, as if that is always the place you're going to click! Anyway, I wrote this little function to get the actual pixel location that you clicked on the screen and return a VELatLong for that. So far it seems pretty accurate (even though I see this as one big, horrible hack - but it's not like we have a choice at the moment).

在我看来,这个问题的示例解决方案只能在屏幕上找到当前地图的中心,就好像这一直是你要点击的地方!无论如何,我写了这个小函数来获取你在屏幕上点击的实际像素位置并返回一个VELatLong。到目前为止它看起来非常准确(尽管我认为这是一个大而可怕的黑客 - 但它并不像我们现在有选择)。

It takes a VEPixel as input, which is the x and y coordinates of where you clicked on the map. You can get that easily enough on the mouse event passed to the onclick handler for the map.

它需要一个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);
}

#3


1  

From the VEMap.GetCenter Method documentation:

从VEMap.GetCenter方法文档:

This method returns null when the map style is set to VEMapStyle.Birdseye or VEMapStyle.BirdseyeHybrid.

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

Here is what I've found, though:

这是我发现的,但是:

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

The (new _xy1) seems to work the same as the old undocumented VEDecoder object.

(new _xy1)似乎与旧的未记录的VEDecoder对象相同。

#4


0  

An interesting point in the Bing Maps Terms of Use.. http://www.microsoft.com/maps/product/terms.html

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

Restriction on use of Bird’s eye aerial imagery: You may not reveal latitude, longitude, altitude or other metadata;

使用鸟瞰航空影像的限制:您可能无法显示纬度,经度,海拔高度或其他元数据;

#5


0  

According to http://dev.live.com/virtualearth/sdk/ this should do the trick:

根据http://dev.live.com/virtualearth/sdk/,这应该做的伎俩:

function GetInfo()         
{
  alert('The latitude,longitude at the center of the map is: '+map.GetCenter());         
}