ThinkGeo.com    |     Documentation    |     Premium Support

ArgumentException when trying to use OpenStreetMapOverlay

I just used the instructions for setting up ThinkGeo for wpf (version 10.1.1).

I tried adding an OpenStreetMap overlay and started getting ArgumentExceptions.

So I simplified the code to this:

var osmOverlay = new OpenStreetMapOverlay();
Map1.Overlays.Add(osmOverlay);

By registering to the events on osmOverlay, I can determine that the tile gets downloaded just fine, however when it tries to draw it, I get this exception:

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)
at cSQ =.eSQ =.CreateDefault(Int32 width, Int32 height)
at ThinkGeo.MapSuite.Drawing.GeoImage.CreateNewNativeImage(Int32 width, Int32 height)
at ThinkGeo.MapSuite.Portable.PclGraphicsFactory.GetStretchedImage(GeoImage image, DrawingRectangleF targetRectangle, DrawingRectangleF sourceRectangle)
at ThinkGeo.MapSuite.Wpf.OpenStreetMapLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.ZyU=(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Wpf.LayerTile.81U= (Layer layer, ThreadSafetyLevel threadSaftyLevel, GeoCanvas geoCanvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Wpf.LayerTile.8lU= (Layer layer, ThreadSafetyLevel threadSafetyLevel, GeoCanvas geoCanvas, Collection`1 labelsInAllLayers, Action`4 action)
at ThinkGeo.MapSuite.Wpf.LayerTile.DrawCore(GeoCanvas geoCanvas)
at ThinkGeo.MapSuite.Wpf.Tile.Draw(GeoCanvas geoCanvas)

Hi Eric,

We build a simple sample, which based on 10.1.1, and it looks everything works well. OpenStreetMapDemo.zip (9.7 KB)

Could you please modify our sample and reproduce the exception? So we can look into what’s the problem.

Regards,

Don

Hello Don,

I was essentially using the wrong projection.

I had this:

map.MapUnit = GeographyUnit.DecimalDegree;
var osmOverlay = new OpenStreetMapOverlay();
map.Overlays.Add(osmOverlay);
map.CurrentExtent = new ThinkGeo.MapSuite.Shapes.RectangleShape(0, 78, 30, 26);
map.Refresh();

This is from the getting started sample which seems to use 4326, I made sure everything was getting reprojected to 3857 and it all works superbly well (with tile caching enable).

Thank you.

Hi Eric,

I am glad to hear that works.

Any question please feel free to let us know.

Regards,

Don