问题
i have made visibility
to 0 but no luck at all,still loading all data when i load with Google Earth .How to uncheck all folders and inside items so user can select which ever required in later.i am creating KML through c# and i am posting small part of big KML file which i am converting in to KMZ
.What is wrong in following kml
snippet
<?xml version="1.0" encoding="utf-8"?>
<kml:kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:json="http://www.w3.org/2005/Json">
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>Test</kml:name>
<kml:open>1</kml:open>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>2G</kml:name>
<kml:open>1</kml:open>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>Icro</kml:name>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>Working</kml:name>
</kml:Folder>
</kml:Folder>
</kml:Folder>
</kml:Folder>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>3G</kml:name>
<kml:open>1</kml:open>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>Testro</kml:name>
<kml:Folder>
<kml:visibility>0</kml:visibility>
<kml:name>Working</kml:name>
<Document xmlns="http://www.opengis.net/kml/2.2">
<name>POINTS</name>
</Document>
</kml:Folder>
</kml:Folder>
</kml:Folder>
</kml:kml>
回答1:
There is a "feature" in Google Earth that contradicts how the KML 2.2 spec describes data is visible by the visibility of parent folders.
The OGC KML 2.2 Standard states "in order for a Feature to be visible, the kml:visibility tag of all its ancestors shall also be set to 1 or true". This means that having visibility=0 on a parent folder should make all child placemarks contained within the folder not visible.
However, Google Earth implements visibility such that visibility on a child element overrides visibility on parent folders even if the visibility is not explicitly defined (by default visibility=1) and this violates the standard as stated above. This was reported as a bug in 2009 and described here. Google responded to the issue as follows:
“Visibility has always been overridden on the child element level, and changing this would break existing code”
This means all of the KML placemarks that want not to show at startup must explicitly have visibility 0 rather than just setting it once at the Folder/Document level.
来源:https://stackoverflow.com/questions/42353749/how-to-uncheck-folders-in-kml-file