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?
Open or create a map. You'll see your layers in the box on the left. Make the changes you want. Add a layer: Click Add layer.
You can view most simple KML files with Google Earth for Chrome (version 9) or in the Google Earth app on your mobile device. If you're unable to view complex KML files, use Google Earth for desktop (version 7), which supports all KML features.
kmz (Zipped KML format) file in your browser. Free online tool to view KML, KMZ files from the web on a Google map. You can open KML, KMZ files from URL, Google Drive or from your computer.
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 :)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With