I would like to run a C# code to create a map based on OSM. The code is from http://www.codeproject.com/Articles/87944/WPF-Map-Control-using-openstreetmap-org-Data

I can build and run the code at Visual Studio 2013. I need to make the map focus on a given lat/lon. So I added

 myMap.Focus(); // enable manual zoom-in/out 
 myMap.Center(37.806029, -122.407007, 16);

in MainWindow.xaml.cx. I also added

  <map:MapCanvas Latitude="37.806029" Longitude ="-122.407007" Zoom="16" x:Name="myMap"
           />

in MainWindow.xaml But, when I ran the code, I got exception:

  An exception of type 'System.ArgumentOutOfRangeException' occurred in PresentationCore.dll but was not handled in user code

  Additional information: The parameter value must be greater than zero.

The exception occured at:

 public ImageSource CreateImage()
    {
        RenderTargetBitmap bitmap = new RenderTargetBitmap((int)this.**ActualWidth**, (int)this.**ActualHeight**, 96, 96, PixelFormats.Default);
        bitmap.Render(_tilePanel);
        bitmap.Freeze();
        return bitmap;
    }

The "ActualWidth" and "ActualHeight" are all 0s.

How can I set values for them ?

Any help would be appreciated.

asked 04 Oct '15, 23:29

usact's gravatar image

usact
19335
accept rate: 0%

edited 04 Oct '15, 23:36

aseerel4c26's gravatar image

aseerel4c26 ♦
32.1k16239551

1

debugging of your code and/or some other libraries/examples is not really the scope of this help site for OpenStreetMap, in my opinion

(04 Oct '15, 23:35) aseerel4c26 ♦
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×20
×7
×1

question asked: 04 Oct '15, 23:29

question was seen: 1,981 times

last updated: 04 Oct '15, 23:36

powered by OSQA