缩放以显示 bing 地图中的所有位置

发布于 2024-10-05 05:52:15 字数 203 浏览 0 评论 0原文

假设我有 3 个图钉:(1) 加利福尼亚州,(2) 佛罗里达州,(3) 纽约。为了让这三个人都可见,我必须缩小到足够远才能看到整个国家。但可以说我有(1)加利福尼亚州,(2)内华达州,(3)德克萨斯州。我必须缩小才能覆盖美国的西南角。 Windows Phone 7 API 的 bing 地图中是否有任何功能可以帮助我解决此问题。基本上,我想缩小到足以看到一组位置。

谢谢!

Say I have 3 pushpins: (1) California, (2) Florida, (3) New York. In order for all the 3 of them to be visible, I'd have to zoom out far enough to pretty much see the whole country. But say instead of that I had (1) California, (2) Nevada, (3) Texas. I'd have to zoom out only to cover the south west corner of the US. Is there any function in the bing maps for Windows Phone 7 API that helps me with this. Basically, I want to zoom out just enough to see a set of locations.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪也成诗 2024-10-12 05:52:15

是的。这是可能的。
CurrentItems 是我的地图的来源。

var locations = CurrentItems.Select(model => model.Location);
map.SetView(LocationRect.CreateLocationRect(locations));

Yes. it is possible.
CurrentItems is source for my map.

var locations = CurrentItems.Select(model => model.Location);
map.SetView(LocationRect.CreateLocationRect(locations));
我也只是我 2024-10-12 05:52:15

我不知道有什么函数可以直接执行您想要的操作,但是您可以找到包围所有位置的边界框,并且您应该能够将视口设置到该范围。

如果您从一个倒置的盒子开始,其中左下角是(maxVal, maxVal),右上角是(-maxVal, -maxval)。您可以循环遍历所有点,如果该点小于其当前值,则重置左下角;如果该点大于其当前值,则重置右上角。

最终结果将是所有东西都适合的最小盒子。添加一点尺寸以应对舍入误差并确保您的图钉实际上位于地图上,然后设置视口的范围。

I don't know about a function that will do what you want directly, but you can find the bounding box that just surrounds all of your locations and you should be able to set the viewport to that extent.

If you start with an inverted box where the bottom left corner is (maxVal, maxVal) and the top right is (-maxVal, -maxval). you can loop over all your points and reset the bottom left if the point is less than its current value or the top right if it's greater than its current value.

The end result will be the smallest box that everything fits into. Add a little to the size to cope with rounding error and to make sure your pins are actually on the map and then set the extent of the viewport.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文