My KML file is:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<NetworkLink>
<Link>
<href>http://localhost/test.php</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>1</refreshInterval>
</Link>
</NetworkLink>
</Document>
</kml>
Localhost/test.php returns:
<Document>
<Placemark>
<name>Testing</name>
<description>
Test
</description>
<Point>
<altitudeMode>absolute</altitudeMode>
<coordinates>0,0,0</coordinates>
</Point>
</Placemark>
</Document>
When you click on the icon, it opens the ballon that says “test”, then after one second, when the kml is refreshed, the balloon closes, how can I fix this?
In order to have the balloon open, just add an
<open>1</open>tag to the placemarkHowever, this means the placemark will ALWAYS be open (balloon showing) when the link is refreshed.
If you want to refresh the kml and leave the balloon open or closed depending on it’s current state, then you need to look into the UPDATE command instead, and use it to update only certain parts of the currently loaded KML, rather than replacing (reloading) the whole KML.
So it really comes down to, why are you Refreshing the KML in the first place??
EDIT: To answer question in comments
Use the
CHANGEfeature of theUPDATEThat will change the coordinates of a placemark with an
idofpoint123that was loaded in the kml mentioned as thetargetHref(which was loaded via aNetworkLink)