ThinkGeo.com    |     Documentation    |     Premium Support

GoogleMapsOverlay Error

I'm using a GoogleMapsOverlay in a WPF based MapSuite application.  The map displays correctly but often when I'm panning or zooming there's a long pause and I eventually get a System.Net.WebException with the contents "The remote server returned an error: (403) Forbidden." 


Is there something I'm doing wrong?


Here's my source:




mapCtl.MapUnit = GeographyUnit.Meter;

GoogleMapsOverlay overlay = new GoogleMapsOverlay();
overlay.MapType = GoogleMapsMapType.RoadMap;
overlay.Name = "Roads";

mapCtl.Overlays.Add( overlay.Name, overlay );
      
Proj4Projection proj = new Proj4Projection();
proj.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
proj.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString( 4326 );

proj.Open();
mapCtl.CurrentExtent= proj.ConvertToExternalProjection( new RectangleShape( -94.1027, 45.4145, -92.732, 44.4711) );
proj.Close();

mapCtl.Refresh()


 


   


Stack trace of the error:


at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x742ba885258f6c2c(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x88c2a2d6d754e692(IEnumerable`1 xa6f0db4f183189f1)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xe3cee4adb9c72451()

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x4eb49068e137ed8f(InteractionArguments x195facd4ef5d753d)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xfeca3317d3c75bbb(Object xd9272088e65bd176, x6a8380ab1a7ebb4c xc2fd4c0ed406cdb7)

   at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.OnMouseEvent(x6a8380ab1a7ebb4c e)

   at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.AnalyseMouseUp(Double screenX, Double screenY, Double worldX, Double worldY, MapMouseButton mouseButton)

   at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xfb2b8bdcd082873c(Object xd9272088e65bd176, MouseButtonEventArgs xc2fd4c0ed406cdb7)

   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

   at System.Windows.Input.InputManager.ProcessStagingArea()

   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)

   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)

   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)

   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)

   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)

   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)

   at System.Windows.Threading.Dispatcher.Run()

   at System.Windows.Application.RunDispatcher(Object ignore)

   at System.Windows.Application.RunInternal(Window window)

   at System.Windows.Application.Run(Window window)

   at System.Windows.Application.Run()

   at TerraFleet.App.Main() in D:\Dev\ThomTech\TerraFleet\Client\Source\TerraFleet\TerraFleet\obj\Debug\App.g.cs:line 0

   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Threading.ThreadHelper.ThreadStart()


 





Chris,


Thanks for your post and questions.
 
This problem will occur when using the Google maps with a free user, see following “Usage Limits” in Google’ website for more details:
code.google.com/apis/maps/do...taticmaps/
 
Any more questions just feel free to let me know.


Thanks.
 
Yale

Hello Yale, 
  
 I have the same problem even using a license key, when this error comes my aplication crash and I have to start it again, is there any way to know if there is something wrong with the request and cacht the exception before my project crash?. 
  
 Best Regards, 
  
 Leandro

Leandro, 
  
 Yes, you can override the GoogleMapsOverlay and add try … catch … to the DrawCore method like following. 
  
 
  class MyGoogleMapsOverlay : GoogleMapsOverlay
    {
        protected override void DrawCore(GeoCanvas canvas)
        {
            try
            {
                base.DrawCore(canvas);
            }
            catch
            {
                // catch the exception here.
            }
        }
    }

//------------------------------------------

   private void ZoomInAndZoomOut_Load(object sender, EventArgs e) 
        {
            winformsMap1.MapUnit = GeographyUnit.Meter;

            MyGoogleMapsOverlay myGoogleMapsOverlay = new MyGoogleMapsOverlay();
            winformsMap1.Overlays.Add("MyGoogleMapsOverlay", myGoogleMapsOverlay);
            winformsMap1.CurrentExtent = new RectangleShape(-20000000, 20000000, 20000000, -20000000);

            winformsMap1.Refresh();
        }
 
  
 Thanks, 
  
 Ben