Question

I have a KML with high detail imagery organized into super-overlays (created using gdal2tiles.py) that I'm trying to show in Google Maps.

This KML works fine and looks great in Google Earth but when it loads in Google Maps it doesn't load the more detailed image layers when a user zooms in. Here's a screenshot illustration (and a link to the full resolution version):

Google Earth vs. Google Maps KML Detail

Here's the simple code I'm using to display the KML on Google Maps (you can also tinker with a live version on JSFiddle here):

function initialize() {
    var i = 1;
    window.map = new google.maps.Map(document.getElementById('map'), {
        mapTypeId: google.maps.MapTypeId.SATELLITE
    });

    var kmzLayer = new google.maps.KmlLayer('http://towatchlist.com/files/MASTERL2_1393600_01_20130329_1753_1806_V01/doc.kml');
    kmzLayer.setMap(map);

    var bounds = new google.maps.LatLngBounds();
    map.fitBounds(bounds);
}

function loadScript() {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' + 'callback=initialize';
    document.body.appendChild(script);
}

window.onload = loadScript;

To see the KML in Google Earth as it should be displayed, go to the Add menu and Choose 'Network Link' and add this url to the link field. Alternatively, you can download the KMZ version of the same file here.

This seems like a bug in Google Maps, but does anyone know a good workaround or if I'm doing something wrong?

Was it helpful?

Solution

Thanks to a suggestion from a Google employee I changed some settings on gdal2tiles.py to make it generate HTML code for the overlay that works better. I added two flags: -w google and -g <apikey> and used the HTML output of that to create the map and overlay.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top