ThinkGeo.comĀ Ā Ā Ā |Ā Ā Ā Ā  DocumentationĀ Ā Ā Ā |Ā Ā Ā Ā  Premium Support

Errror applying Projection to GoogleMapsLayer with MS 10

Hi,

We have just upgraded to MS 10, WinForms. When we try to display GoogleMaps in a projections other than its native one, we get the following execption:

System.AggregateException was unhandled
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at ThinkGeo.MapSuite.Layers.GoogleMapsLayer.FjY=(RectangleShape canvasExtentForGoogleDrawing, Int32 zoomLevelsNumber, Double scale)
at ThinkGeo.MapSuite.Layers.GoogleMapsLayer.FTY=(GeoCanvas canvas)
at ThinkGeo.MapSuite.Layers.GoogleMapsLayer.DrawCore(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Layers.Layer.dyQ=(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.WinForms.LayerOverlay.DrawCore(GeoCanvas canvas) at ThinkGeo.MapSuite.WinForms.Overlay.9FI=(GeoCanvas canvas) at ThinkGeo.MapSuite.WinForms.Overlay.Draw(GeoCanvas canvas) at ThinkGeo.MapSuite.WinForms.WinformsMap.rVI=(IEnumerable1 drawingOverlays, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.rFI=(RectangleShape drawingExtent, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.y1I=(RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.fhU=(Int32 delayInterval, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.Refresh()
at MapSuite_Desktop1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\ZipPa\Documents\Visual Studio 2015\Projects\ThinkGeo\GoogleMapsTest\Form1.vb:line 26
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
HResult=-2146233079
Message=failed to load NAD27-83 correction file
Source=ThinkGeo.MapSuite
StackTrace:
at ThinkGeo.MapSuite.Shapes.Proj4Projection.wCI=(Int32 errorNumber)
at ThinkGeo.MapSuite.Shapes.Proj4Projection.ConvertToExternalProjectionCore(Double[] x, Double[] y)
at ThinkGeo.MapSuite.Shapes.Projection.yiI=(Byte[] wellKnownBinary)
at ThinkGeo.MapSuite.Shapes.Projection.xyI=(Byte[] wellKnownBinary)
at ThinkGeo.MapSuite.Shapes.Projection.wyI=(Feature feature)
at ThinkGeo.MapSuite.Shapes.Projection.ConvertToExternalProjection(BaseShape baseShape)
at ThinkGeo.MapSuite.Layers.GoogleMapsLayer.FzY=(Object tileInfo)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
InnerException:

I have attached a sample project for you to see the problem.

Thanks!

Steve
GoogleMapsTest.zip (37.7 KB)

Steven1,

I tried your sample application. I assume that you have a valid key in your application, but a key isnā€™t needed for testing purposes. I actually commented out that whole line.

Protected Overrides Sub OnCreatingRequest(e As CreatingRequestGoogleMapsLayerEventArgs)
        'e.RequestUri = New Uri(e.RequestUri.AbsoluteUri + "&key=")
        MyBase.OnCreatingRequest(e)
	End Sub

Before that though, my first issue was getting the references correct. I went ahead and updated your references to 10.2. I noticed that the package manager was showing ThinkGeo.MapSuite.Shapes.UnmanagedProj4Projection installed, but it wasnā€™t installed correctly (This could have been a local issue for me). I removed that reference, and I reinstalled it. Despite VS 2017 saying it was using the package, it didnā€™t include the folders in the output location (There should be 4 folders copied to the output location. Windows-X86, Windows-X64, Linux-X86, and Linux-X64), and I was getting errors thrown at me . After the reinstall, it worked great without error.

I made no changes other than the one comment to your code. These are your packages:

<?xml version="1.0" encoding="utf-8"?>

  
  
  
  
  
  
  
  
  
  
  

These are the ones I used:

<?xml version="1.0" encoding="utf-8"?>

  
  
  
  
  
  
  
  
  
  
  
  

Hopefully, that will get you what you need. I think the issue might be that your packages are different versions. If you update, I would recommend doing ThinkGeo.MapSuite first. Then, updating the rest. Having done this several times myself recently, the package manager will tell you that ThinkGeo.MapSuite 1.0 (1.1) does not meet the prerequisites for all the other 10.2 packages and fail. Update that one individually, then the others will update without issue. Good Luck!

Hi Steven,

Just like Brandon mentioned, the problem is because you missed the package: ThinkGeo.MapSuite.Shapes.UnmanagedProj4Projection

Please install that and upgrade all you package into 10.2.

Regards,

Ethan

Brandon_Cook/Ethan

Thanks for taking the time to respond. I would love to upgrade to MS 10.2 or 10.2.1 but I canā€™t. In our application we use the print preview capabilities of MS to create a Page-Layout view for printing, which relies on PrinterInteractiveOverlay. This class works fine in 10.0 but will not work in later versions. I donā€™t know how or why, but this class is listed twice in the object browser in VS and if you try to create an instance of it you get the ā€˜name is ambiguous in the namespaceā€™ error message and the project will not compile.

I have not been successful in getting the GoogleMaps issue solved in version 10.0.

So, ThinkGeo guys, any idea about when PrinterInteractiveOverlay will work in a current version of MS?

Thanks!

Steve

Hi Steven,

I tried you sample and can reproduce that in one of my VM machine, I think we will do further test based on that and let you know whatā€™s the status.

Regards,

Don

Ethan,

Sounds like the previous response was posted to the wrong thread.

Steve

Hi Steve,

Thanks for your remind!

I will edit the reply.

Regards,

Ethan

Hi Steve,

Our developer did further research about your sample, and found the problem is caused by the projection.

As below is the detail reply about that:

We got the proj4 string from the epsg code 102003:
ā€œ+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defsā€

This projection is a grid projection, the datum is ā€œNAD83ā€. As so far, this projection isnā€™t supported in Map Suite projection.

If removed the projection, the sample works well in our side.

And if your machine cannot directly connect to Googleā€™s server, please set proxy if you are using some utility like shadowsocks.

BTW, Our developer keep look into it, maybe we will update this post again if any news.

Regards,

Ethan

Hi Ethan,

We have been using Srid 102003 since MS began supporting reprojection of raster layers (a number of years). It works fine in ThinkGeo 9. And the ability to display Google Maps in this coordinate system is a key part of our application.

Also, if I try to use Srid 26916 that fails as well.

I donā€™t think you guys have removed support for this projection. I think the error in my original sample is misleading you. And it was confusing to me also.

I re-created another sample from scratch (instead of starting with an old one). I am using all MS 10.2 or MS 10.21 assemblies. Now I am getting a different error, and I think it might be helpful. The exception I am now receiving suggests that MapSuite cannot find the Unmanaged Proj4 Dependencies, even though they have been added to the project.

Google Bug.zip (19.0 KB)

Please give it a try.

Thanks,

Steve

.

Hi Steve,

Our developer found it should be an issue for Proj4Projection, so the workaround is to use UnmanagedProj4Projection, you should want to download this package: ThinkGeo.MapSuite.Shapes.UnmanagedProj4Projection.

As below is the code and the screen shot:

Dim oProj As New UnmanagedProj4Projection
With oProj
.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString
.ExternalProjectionParametersString = Proj4Projection.GetEsriParametersString(26916)
.Open()
End With

We tested the version 9 and found the ManagedProj4 also donā€™t works for it.

Our developer will work for it and try to fix that in Proj4Projection, any update we will let you know.

Regards,

Ethan

1 Like

Ethan,

Thanks for your help. I didnā€™t realize there was an UnhandledPoj4Projection class. That finally got it working.

Thanks again!

Steve

Hi Steve,

Thanks for your update.

Any question please let us know.

Regards,

Ethan