Google Earth JS API 中的 LatLngBounds?
我正在 Google Earth API 中寻找类似于谷歌地图“LatLngBounds”的内容,但我在 Google 地球 API 参考。
我需要这个来将相机视图集中在放置的所有标记/地标上,并缩放到适当的级别。
有这样的事吗?还是我需要自己做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看 Earth API Utility Library,特别是 computeBounds() 函数。
请注意,它会遍历 KML DOM 并在边界上求和,因此它可能会相当慢,具体取决于您想要在视图中显示的对象的数量,并且在计算该视图时它会很保守,因此边界最终可能会大于是最优的。不过,如果您想利用现有的内容并对其进行自定义,则可以使用源代码。
You might check out the Earth API Utility Library, specifically the computeBounds() function.
Note that it walks the KML DOM and sums over the bounds, so it might be rather slow depending on the number of objects you want to have in view, and it will be conservative when calculating that view, so the bounds may end up larger than is optimal. If you want to take what's there and customize it, though, the source code is right there for the taking.