I recently updated a map from V2 to V3 and I am working on incorporating code to automatically refresh the KML data every 30 seconds. The goal is to update the map with the latest data and display a countdown until the next refresh.
Here is an example of how it worked in V2: V2 EXAMPLE
I have made updates to the relevant code in V3 but unfortunately, it's not functioning as expected. Despite not encountering any errors, the code that worked perfectly in V2 isn't cooperating in V3. I'm struggling to pinpoint what I may be overlooking. What could be missing or causing this discrepancy between V2 and V3?
//This calls genkml.php on every refresh cycle to generate a new kml file
function UpdateKML() {
// Code for updating KML
}
// Function for displaying current time based on different parameters
function CurrentTime (type, hours, secs, ofs) {
// Code for determining current time based on type
}
// Function for setting debug mode
function debug(obj){
// Code for toggling debug mode
}
// Function for enabling forced update
function forceupdate(obj){
// Code for forcing update
}
// Function for retrieving query parameter value
function gup( name ){
// Code for parsing out query parameter value
}
If needed, here is the link to the full .js map code for V3: V3 NSGAMP CODE
For reference, here are links to the full page and related snippets of code:
- V3 FULL PAGE
- EDIT: Excerpt of code for updating KML data in V2
- Depreciated V2 Code Snippet
- Updated V3 Code Snippet:
- Refreshed V3 Code
Deprecated V2 Code Snippet:
// Deprecated code snippet for updating overlays in V2
map.removeOverlay(geoXml);
geoXml = new GGeoXml(URLToKML + "?rand="+(new Date()).valueOf());
map.addOverlay(geoXml);
Updated V3 Code Snippet:
// Updated code snippet for refreshing KML data in V3
nyLayer = new google.maps.KmlLayer(null);
nyLayer.setMap(null);
function refresh(layer) {
var nyLayer = new google.maps.KmlLayer(URLToKML + "?rand=" + (new Date()).valueOf(), {
suppressInfoWindows: false,
map: map,
preserveViewport: true,
zIndex: 999
});
}