Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixes ZEN-2399 with a smarter delay feature. reviewed by jcausey
Index: /trunk/core/Products/ZenWidgets/skins/zenui/javascript/geomap.js
===================================================================
--- /trunk/core/Products/ZenWidgets/skins/zenui/javascript/geomap.js (revision 62411)
+++ /trunk/core/Products/ZenWidgets/skins/zenui/javascript/geomap.js (revision 62520)
@@ -19,4 +19,5 @@
var nodedata = null;
var linkdata = null;
+ var errorCount = 0;
/* PUBLICIZE */
@@ -99,4 +100,15 @@
dialog.innerHTML = content;
_overlay.constructMarker(results, true);
+ }else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
+ /* try the address a few times after some delay to make sure it really is a query limit
+ problem and not just erroring becuase we hit it too many times a second. We can get
+ this error when the user has reached their daily limit for their IP as well.
+ */
+ errorCount++;
+ if(errorCount >= 5){
+ _utils.statusDialog("QUERY_LIMIT error. If this is a free account, you may have reached your daily limit. Please try again later.");
+ return false;
+ }
+ setTimeout(function(){_overlay.addMarkers()}, 2000);
}else{
_utils.statusDialog(status);
@@ -145,4 +157,15 @@
}
});
+ }else if(status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
+ /* try the address a few times after some delay to make sure it really is a query limit
+ problem and not just erroring becuase we hit it too many times a second. We can get
+ this error when the user has reached their daily limit for their IP as well.
+ */
+ errorCount++;
+ if(errorCount >= 5){
+ _utils.statusDialog("QUERY_LIMIT error. If this is a free account, you may have reached your daily limit. Please try again later.");
+ return false;
+ }
+ setTimeout(function(){_overlay.addPolyline()}, 2000);
}else{
_utils.statusDialog(status);
@@ -208,5 +231,5 @@
// need a delay here to keep google from saying: OVER_QUERY_LIMIT
// due to having too many queries per second
- setTimeout(function(){_overlay.addMarkers()}, 200);
+ setTimeout(function(){_overlay.addMarkers()}, 400);
}
@@ -238,5 +261,5 @@
}else{
// done with that line, but wait, there's more...
- setTimeout(function(){_overlay.addPolyline()}, 200);
+ setTimeout(function(){_overlay.addPolyline()}, 400);
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.