Loop KML Overlay

319 views
Skip to first unread message

Chris Wilson

unread,
Jun 20, 2011, 6:39:24 PM6/20/11
to google-map...@googlegroups.com
Hey,

Been looking around for a couple of hours, i'm trying to find a way to loop my kml data overlay....

I'm pulling data from the NWS (radar loops) and it plays once, then stops....Cant seem to find any information on controls...I'd like to get it to indefinitely loop.

function initialize() {
  var chicago = new google.maps.LatLng(39.715, -96.106);
  var myOptions = {
    zoom: 11,
    center: chicago,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  var ctaLayer = new google.maps.KmlLayer('http://www.srh.noaa.gov/ridge/kml/animation/N0R/SGF_N0R_loop.kml');
  ctaLayer.setMap(map);
}
</script>
</head>
<html>
<body onload="initialize()">

<div id="map_canvas" style="width:550px; height:600px; float:left"></div>


Any help would be appreciated.

Jennifer Dudeck

unread,
Jun 30, 2011, 10:10:47 AM6/30/11
to Google Maps JavaScript API v3
What do you mean by "looping"? It looks like the KML file is
continually updated, so I'm guessing you want the map to keep
refreshing the KML layer to keep the visuals constantly moving.

You can use a Network Link in a KML file that has a refresh interval
set. I tried this, and it seemed to work pretty well:

<?xml version="1.0" encoding="UTF-8"?>
<NetworkLink>
<visibility>0</visibility>
<open>0</open>
<refreshVisibility>0</refreshVisibility>
<flyToView>0</flyToView>
<Link>
<href>http://www.srh.noaa.gov/ridge/kml/animation/N0R/
SGF_N0R_loop.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>2</refreshInterval>

</Link>
</NetworkLink>


The <refreshInterval>2</refreshInterval> part means that ever 2
seconds, it will refresh the overlay.
To learn more about Network Links, check here:
http://code.google.com/apis/kml/documentation/kml_tut.html#network_links
Reply all
Reply to author
Forward
0 new messages