c# - 设置 Bing map 缩放更大的位置 React

标签 c# bing-maps windows-8.1

我正在尝试将 Bing map 的缩放级别设置为比 LocationRect 稍微靠后。我环顾四周,找不到任何关于它的东西。这是设置 map View 的代码

myMap.SetView(new LocationRect(locationCollection));

用于 Windows 8 App XAML/C#: Set multiple pushpins to Bing map in one method

最佳答案

我遇到过几次。通常人们从图钉使用的位置集合创建一个 LocationRect,然后设置 View 以发现某些图钉不在 View 中。这是因为 LocationRect 没有考虑图钉的像素大小,只关注坐标。在 V7 中,我们有一个添加填充的选项,但 Windows Store SDK 中没有这个相同的选项。我前一段时间写了一篇博文,内容是关于如何根据带有缓冲区 () 的位置集合计算最佳 map View 。使用它,我将这种可重用的方法放在一起,用于计算带缓冲区的边界框的缩放级别。然后,您可以使用此缩放级别和 LocationRect 的中心属性来设置 map View 。

public double CalculateZoomLevel(LocationRect boundingBox, double buffer, Map map)
{
    double zoom1=0, zoom2=0; 

    //best zoom level based on map width
    zoom1 = Math.Log(360.0 / 256.0 * (map.ActualWidth - 2*buffer) / boundingBox.Width) / Math.Log(2);

    //best zoom level based on map height
    zoom2 = Math.Log(180.0 / 256.0 * (map.ActualHeight - 2*buffer) / boundingBox.Height) / Math.Log(2);

    //use the most zoomed out of the two zoom levels
    var zoomLevel = (zoom1 < zoom2) ? zoom1 : zoom2;

    return zoomLevel;
}

关于c# - 设置 Bing map 缩放更大的位置 React,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22402830/

相关文章:

vim - 使用触摸屏设备在 GVim 中滚动

c# - 在 .NET 应用程序中处理大型数组的性能

c# - MySQL - 当类似的 CREATE TABLE 不存在时,CREATE TABLE 会引发错误

c# - 从 ViewModel 中选择 TabControl 中的 TabItem

javascript - Bing map 信息框

mysql - XAMPP 未在 Window 8.1 中运行

c# - 如何在 Epplus ExcelWorksheet 中查找日期时间值

javascript - Windows 8 应用程序 : Bing maps javascript

javascript - 如何在 bing map 中绘制路径或线两个图钉?

Windows 8.1/IE11 自定义 URL 协议(protocol)打开 --> 关于 :blank