Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a superoverlay using MapTiler and am displaying that in a webpage with the Google Earth plugin. I'd like to identify the current tile (level, x, y) being displayed with a mousemove event. I'm able to get the current lat/lon using getGlobe(), e.g., 'mousemove', function(e) {
    var lat = e.getLatitude();
    var lon = e.getLongitude();

The biggest hurdle seems to be getting the correct superoverlay level based on camera altitude as the transition between levels is dictated by the minLodPixels parameter in the KML files. I'm not sure how best to determine when a tile is, say, 128 pixels wide on the screen, especially when this will be based on how large the map window div is.

Once the level is determined, it should be trivial to figure out the X, Y offsets of the tile. I'm also assuming that the minLodPixels/maxLodPixels parameters will stay consistent across all tiles in the superoverlay (MapTiler has these at 128/-1).

Any thoughts?

Update 2012.02.22

I've delved a bit further into this and found some good documentation on minLod in the KML documentation. From,

Google Earth calculates the size of the Region when projected onto screen space. Then it computes the square root of the Region's area (if, for example, the Region is square and the viewpoint is directly above the Region, and the Region is not tilted, this measurement is equal to the width of the projected Region). If this measurement falls within the limits defined by and (and if the is in view), the Region is active.

So if I'm able to find out the screen real estate of each hierarchical tile at a particular LookAt, I should be able to find the level I'm at based on what tile minimally exceeds the minLod threshold. As a test, I've read the SuperOverlay's root KML ('doc.kml') and retrieved the coarsest tile bounds:

var INFO = '/path/to/doc.kml';
$.get(INFO, function(data) {
    // Get the corners of the coarsest resolution
    var box = $(data).find("LatLonAltBox");
    north = parseFloat($(box).find("north").text());
    south = parseFloat($(box).find("south").text());
    east = parseFloat($(box).find("east").text());
    west = parseFloat($(box).find("west").text());

From there, I calculate area on the mousemove event of GEWindow., 'mousemove', function(e) {

    // Track the screen coordinates of the coarsest tile
    var view = ge.getView();
    var alt_mode = ge.ALTITUDE_RELATIVE_TO_GROUND;
    var ne = view.project(north, east, 0.0, alt_mode);
    var se = view.project(south, east, 0.0, alt_mode);
    var sw = view.project(south, west, 0.0, alt_mode);
    var nw = view.project(north, west, 0.0, alt_mode);

    // Get the square-root of area (using equation 3 from 
    var qX = (se.getX() - nw.getX());
    var qY = (se.getY() - nw.getY());
    var pX = (sw.getX() - ne.getX());
    var pY = (sw.getY() - ne.getY());
    var area = Math.sqrt(0.5 * Math.abs(qX * pY - pX * qY));

When I track the tile's visibility in GE though, it disappears at a value higher than 128 (the minLod) when viewed without tilt, and appears at a value lower than 128 when viewed with tilt. I don't have enough rep to post pictures, but I've posted example screenshots here. In these pictures, the white polyline shows the tile boundary. I'm obviously still doing something incorrectly.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.