Is there any way to show a kml Layer only on Google Earth view layer? I am using Google API V3
This is the link of what I have: http://www.virtualbc.ca/knoxmountain/inde
You can use the maptypeid_changed event on the Google.Map object. When it changes, you can either set the kml layer to show or hide by using setMap(). Example:
function initialize() {
var map = new google.maps.Map(document.getElementById('map-div'), {
center: new google.maps.LatLng(40.3,-111.65),
zoom: 13
});
var kmlLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
kmlLayer.setMap(map);
google.maps.event.addListener(map, 'maptypeid_changed', function() {
if(map.mapTypeId == 'hybrid') {
kmlLayer.setMap(null);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
Just make sure that when you set the map type back to a different one you re-set the kml layer to the map. When you want to hide something, you just call setMap(null).