尝试处理一些调查数据(目前提取相同的json文件(关于如何关闭变量边界有什么想法吗?我试过明显和夸张的风格,但似乎无法破解。
// Call the variables for a new map
Boundaries = new google.maps.Data();
Road = new google.maps.Data();
// Set variable to load json files/data
Boundaries.loadGeoJson('StageBoundariesLayer.json');
Road.loadGeoJson('StageBoundariesLayer.json');
// Set style of the variables/layers
Boundaries.setStyle({
visible: true,
strokeColor: 'yellow',
strokeWeight: 5
});
Road.setStyle({
visibility: true,
strokeColor: 'red',
strokeWeight: 1
});
Boundaries.setMap(map);
Road.setMap(map);
document.getElementById('button1').addEventListener('click', toggleBoundaries);
function toggleBoundaries(){
if (Boundaries.overrideStyle.visible === true){
Boundaries.setStyle.visible = false;
} else {
Boundaries.setStyle.visible = true;
}
};
toggleBoundaries();
document.getElementById('button1').addEventListener('click', toggleBoundaries);
function toggleBoundaries() {
if (Boundaries.getMap() != null) {
Boundaries.setMap(null);
} else {
Boundaries.setMap(map);
}
}
toggleBoundaries();