Search code examples
javascriptgoogle-earth-plugin

getViewportGlobeBounds return non accurate values


When I manually compare the values returned from GEView.getViewportGlobeBounds function to the actual view I on screen I see minor (but significant for my current needs) differences.

Actually, in most cases the values that returned from the function aren't in the view.

Why does this is happen? Is there a way to get more accurate values?

Edit (code):

function getExtentNorth() {
  document.getElementById("ExtentNorth").value=ge.getView().getViewportGlobeBounds().getNorth ();
}

Solution

  • This is the expected behaviour, if you read the documentation for GEView.getViewportGlobeBounds you can see that it...

    Returns a bounding box that completely contains the region of the globe that is currently visible. The returned box will be larger than what is strictly visible, if that is necessary to include everything that is visible.

    (my emphasis)

    The way the projection to screen works means the bounding box will almost always contain more than the currently visible region, since each bound contains the furthest visible point in each direction.

    So, when you are viewing the earth at anything other than 'close to' and 'straight down' that is exactly the result you should expect.

    This principal is illustrated really well in this example.