kml图层是只能控制一个layer3d的显隐吗,我只要两个图层一起设置显隐就报错,报错信息如下:
createFile(layerKMlPath_c);
scene.getLayers().addLayerWith(layerKMlPath_c,Layer3DType.KML,false,"轨迹路线");
Layer3D layer3d_c = scene.getLayers().get("轨迹路线");
feature3D_c.toKMLFile(layerKMlPath_c);
layer3d_c.getFeatures().add(feature3D_c);
Switch switch_c = findViewById(R.id.switch_c);
//标注图层
createFile(layerKMlPath_bz);
scene.getLayers().addLayerWith(layerKMlPath_bz,Layer3DType.KML,false,"标注图层");
Layer3D layer3d_bz = scene.getLayers().get("标注图层");
feature3Ds_bz.toKMLFile(layerKMlPath_bz);
layer3d_bz.getFeatures().add(feature3Ds_bz);
//layer3d_bz.setVisible(true);
//switch_c.setChecked(true);
switch_c.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b) {
// Switch被打开
Toast.makeText(MainActivity.this, "路线显示", Toast.LENGTH_SHORT).show();
layer3d_c.setVisible(true);
layer3d_bz.setVisible(true);
} else {
// Switch被关闭
Toast.makeText(MainActivity.this, "路线隐藏", Toast.LENGTH_SHORT).show();
scene.getTrackingLayer().clear();
layer3d_c.setVisible(false);
layer3d_bz.setVisible(false);
}
}
});
请问该如何解决呢