Ross Coulbeck
Ross Coulbeck

Reputation: 612

Adding Kml Layer to google map

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?

Upvotes: 7

Views: 12006

Answers (2)

Ross Coulbeck
Ross Coulbeck

Reputation: 612

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 :)

Upvotes: 7

jlivni
jlivni

Reputation: 4779

Does your layer display at http://maps.google.com?q=http://your.site/your.kml ?

If not, there's probably something wrong with your KML. Perhaps, for example, all the features are set to visibility being off. A link to your KML would help troubleshooting.

Upvotes: 3

Related Questions