I've tried what you suggested, but this does not always work. I am also handing the zoom event since this would also cause request to be sent. Here is my test code:
private void LoadGoogleMapOverlay(Int32 zoomLevel, RectangleShape recShape)
{
//add the Google Map overlay
map1.MapUnit = GeographyUnit.Meter;
map1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 0, 0, 66));
map1.MapZoomed += OnMapZoom;
ExtendedGoogleMapOverlay gLayer = new ExtendedGoogleMapOverlay();
gLayer.MapType = GoogleMapsMapType.Hybrid;
gLayer.CacheDirectory = @"C:\MapImages";
gLayer.TransitionEffect = TransitionEffect.Stretch;
gLayer.DrawingExceptionMode = DrawingExceptionMode.ThrowException;
gLayer.DrawingTile += OnTileDrawing;
.
.
.
}
private void OnTileDrawing(object sender, DrawingTileTileOverlayEventArgs e)
{
CheckTileFetchAvailable();
}
private void OnMapZoom(object sender, MapZoomEventArgs e)
{
CheckTileFetchAvailable();
}
private void CheckTileFetchAvailable()
{
lock(_LastTileFecthLock)
{
//Google allows 5 request/second free license and 10 request/second premier license
while((DateTime.Now - _LastTileFetchTime).TotalMilliseconds <= 300)
{
Thread.Sleep(10);
}
_LastTileFetchTime = DateTime.Now;
}
}
This test code above did not solve the problem. It seems as if the tile request is being sent before the DrawingTile event is fired. The ideal solution to this problem would be to receive an event just before the actual request to the server is sent. Would it be possible for an event to be added which would fire before the tile request is sent so that we could perform throttling?