Search code examples
google-mapsmapskml

Google Map KML Auto refresh


I have kml google map which does not auto refresh. Does anybody have an idea how to do it?

My kml code:

<kml xmlns="http://earth.google.com/kml/2.0">
    <Document>
        <visiblity>1</visiblity>
        <NetworkLink>
            <name>USGS WaterWatch</name>
            <flyToView>1</flyToView>
            <Url>
                <href><![CDATA[http://waterwatch.usgs.gov/?m=real&w=kml&regions=co]]></href>
                <refreshMode>onInterval</refreshMode>
                <refreshInterval>3600</refreshInterval>
                <viewRefreshMode>never</viewRefreshMode>
                <viewRefreshTime>1800</viewRefreshTime>
            </Url>
            <refreshVisibility>1</refreshVisibility>
        </NetworkLink>
    </Document>
</kml>

Solution

  • Some KML elements are not supported in Google Maps.

    For example, the <refreshVisibility> element is not supported.

    List of limitations of KML in Maps can be found here:
    https://developers.google.com/kml/documentation/kmlelementsinmaps

    There are also some validation errors in your KML. The spelling and order of elements in KML is strict. The visiblity element must be renamed to visibility and order of elements in NetworkLink must be reordered: flyToView, refreshVisibility, Url. The namespace used is the older one and the Url element is deprecated. Suggest you update the KML to the following:

    <kml xmlns="http://www.opengis.net/kml/2.2">
        <NetworkLink>
            <name>USGS WaterWatch</name>            
            <refreshVisibility>1</refreshVisibility>
            <flyToView>1</flyToView>
            <Link>
                <href><![CDATA[http://waterwatch.usgs.gov/?m=real&w=kml&regions=co]]></href>
                <refreshMode>onInterval</refreshMode>
                <refreshInterval>3600</refreshInterval>
                <viewRefreshMode>never</viewRefreshMode>
                <viewRefreshTime>1800</viewRefreshTime>
            </Link>
        </NetworkLink>
    </kml>