Adding Kml Layer to google map

Ross Coulbeck picture Ross Coulbeck · Apr 5, 2012 · Viewed 11.7k times · Source

I'm trying to add a couple of KML layers to a map. This is the code I have:

    var myKmlOptions = {
        preserveViewport: true,
        suppressInfoWindows: true
    }

    var kmlLayer_1 = new google.maps.KmlLayer("Layers/layer1.kml", myKmlOptions);
    var kmlLayer_2 = new google.maps.KmlLayer("Layers/layer2.kml", myKmlOptions);
    kmlLayer_1.setMap(map);
    kmlLayer_2.setMap(map);

Something is definately working because if I change preserveViewport to false, the map zooms closer into the area defined by the KML Layer.

But nothing is showing up, the layer its self is missing :/

Any ideas?

Answer

Ross Coulbeck picture Ross Coulbeck · Apr 10, 2012

Solved the problem in the end. The problem was that this was all being done on a dev server and I learnt that for google to access the KML files they need to be on a live site!

Temporarily put them on another live site to reference while I'm still working on development.

Thanks for help :)