I have unsuccessfully tried to create a toggle (checkbox) for my google
fusion tables layer which should work with the toggling of my kml layers
(the kml layers toggle off and on my map successfully). Here are some
snippets of code that I am using to code the klm layers and the one google
fusion layer. I have not included a bunch of other coding, including the
pie and scatter plots (also referencing the fusion table layer). Thanks in
advance for any help!
function initialize() {
var myOptions = {
center: new google.maps.LatLng(38.099983, -80.683594),
zoom: 7,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_RIGHT
},
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE
},
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
//the "layer" is the one I am trying to have function with a toggle
var layer = new google.maps.FusionTablesLayer();
updateLayerQuery(layer);
layer.setMap(null);
var kmlLayerWildernessURL =
'http://www.esenvironmental.com/kml/wilderness.kml';
var kmlLayerBoundaryURL =
'http://www.esenvironmental.com/kml/study_region.kml';
var kmlOptions = {
preserveViewport: true
};
kmlLayerWilderness = new google.maps.KmlLayer(kmlLayerWildernessURL,
kmlOptions);
kmlLayerWilderness.setMap(null);
kmlLayerBoundary = new google.maps.KmlLayer(kmlLayerBoundaryURL,
kmlOptions);
kmlLayerBoundary.setMap(map);
document.getElementById('show_hide_KML_Layer_Wilderness').checked = false;
document.getElementById('show_hide_KML_Layer_Boundary').checked = true;
document.getElementById('show_hide_Layer').checked = false;
function toggleKMLLayerBoundary() {
if
(!document.getElementById('show_hide_KML_Layer_Boundary').checked)
kmlLayerBoundary.setMap(null);
else
kmlLayerBoundary.setMap(map);
}
function toggleKMLLayerWilderness() {
if
(!document.getElementById('show_hide_KML_Layer_Wilderness').checked)
kmlLayerWilderness.setMap(null);
else
kmlLayerWilderness.setMap(map);
}
function ToggleLayer() {
var chkLayer = document.getElementById("chkLayer");
if (chkLayer.checked === true) {
//Turn layer on
layer.setMap(map);
}
else {
//Turn layer off
layer.setMap(null);
}
}
<!-- Below is the code for the checkboxes: -->
Show:<input type="checkbox" id="show_hide_KML_Layer_Boundary"
onClick="toggleKMLLayerBoundary();" />Study Area<p>
Show:<input type="checkbox" id="show_hide_KML_Layer_Wilderness"
onClick="toggleKMLLayerWilderness();" />Wilderness<p>
Show:<input type="checkbox" id="show_hide_Layer" onClick="toggleLayer();"
/>Sites<p>
<!-- Above is the code for the checkboxes: -->
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/oJxpvEPGSAoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.