我有一个利用 Google Earth 的 Windows 窗体应用程序,用户可以在地图上绘制一个多边形,用作地理围栏。
我想做的是能够缩放到多边形,以便通过单击按钮它可以很好地适应屏幕。一种缩放以适应功能。
找到多边形的中心并将 Google Earth 相机设置为该纬度/经度很容易。
我需要的是一种算法,它采用纬度\经度、屏幕高度\宽度的边界框,然后确定设置相机的高度。
有人有这个算法或者知道在哪里可以找到吗?
谢谢!!
I got a Windows Forms app making use of Google Earth where users can draw a polygon on the map which is used as a geofence.
What I'd like to do is to be able to zoom to the polygon so that it fits nicely on screen with a click of a button. A sort of zoom to fit function.
Finding the centre of the polygon and setting the Google Earth camera to that lat/long is easy.
What I need is an algorithm that takes a bounding box of lats \ longs, screen height \ width and then determines the altitude to set the camera.
Does anyone have this algorithm or know where one can be found?
Thanks!!
发布评论
评论(1)
要“缩放到多边形”或任何其他
KmlObject
,最简单的方法可能是使用 earth-api-utility-library。请参阅方法 createBoundsView、setToBoundsView尤其是 flyToObject
例如,其中
ge
是GEPlugin
对象,polygon
是KmlPolygon
。To "zoom to the polygon" or any other
KmlObject
it is probably easiest to use the earth-api-utility-library.See the methods createBoundsView, setToBoundsView and especially flyToObject
For example, where
ge
is theGEPlugin
object andpolygon
is aKmlPolygon
.