NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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.6k18248554

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 ♦

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:

×25
×8
×1

question asked: 04 Oct '15, 23:29

question was seen: 2,707 times

last updated: 04 Oct '15, 23:36

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum