ThinkGeo.com    |     Documentation    |     Premium Support

Scale issue when map control occupies part of the vertical space

I've configured my WPF map with some predefined scales and put the map control on the right side pane of a grid control.


But I'm experiencing some issues with that, like the scales not being exactly as those that I configured and also a wierd behavior when I maximize and minimize the map a few times, scaling up the map until it return to its initial scale.


I`ve hosted the project in the following URL:


tidybits.com/ScaleWPF.rar


Commenting the lines between  and  in the .xaml will produce the expected behavior.


What is going on?


Edit: Also, the layer tracking when you drag the map doesn't work.



Gustavo,


Try change the following lines in your .xaml to see if it works:

<Grid Name="canvasMap" Grid.Column="2" SizeChanged="Grid_SizeChanged" Width="580">
<my:WpfMap DockPanel.Dock="Top" Name="wpfMap" Margin="0"  MapResizeMode="PreserveScaleAndCenter" />
</Grid>

 
Besides, we have a post talking about the dock of the wpf control, try their samples if you are interested.
gis.thinkgeo.com/Support/Dis...fault.aspx
 
Any more questions just let me know.
 
Thanks.
 
Yale
 

Hi Yale, 
  
 I went in a slightly different way too. First, I set the Width and Height of the map in the .xaml declaration. After the map initialization and after the call to wpfMap.Refresh() I assigned the SizeChanged event handler to the Grid. So that when the app first launch the SizeShanged event won’t fire. But as soon as I maximize the window, the SizeChanged event will fire, and the mess begin. The problem is when the event fires and sets a different dimension to the map. This approach using the SizeChanged event works like a charm if the map occupies the entire vertical area available, but my map will be on the right side pane, as in the sample code I provided. 
 I don’t know how to get around this problem. I don’t understand why such a basic feature gets so difficult to implement.  
 I would really appreciate a sample or an implementation idea with all those variables begin considered.  


Gustavo,


Thanks for your post.


This is a bug for the event CurrentScaleChanged for Winforms and Wpf Mapcontrol, I have fixed this issue and it should be available in next release.


Now, if you want to go around this problem, please use the following event instead:



wpfMap.CurrentExtentChanged += new EventHandler<CurrentExtentChangedWpfMapEventArgs>(wpfMap_CurrentExtentChanged);

void wpfMap_CurrentExtentChanged(object sender, CurrentExtentChangedWpfMapEventArgs e)
{
      double scale =  ExtentHelper.GetScale(e.CurrentExtent, (float)e.MapWidth, e.MapUnit);
      currentMapScale.Text = scale.ToString();
}

Any more questions just feel free to let me know.


Thanks.


Yale

 



Yale,  
  
 that only solved the scale difference in the label. I still have the drag issue, where the map being dragged doesn’t show during the mouse dragging. Also, if I keep minimizing/maximizing the map it scales up each time.

Gustavo,


Thanks for your reply.
 
I think the map is going to draw continuously when dragging the mapping to resize. Can you have a try on the following simple sample to see its effects?
 
If I am misunderstanding anything, please feel free to let me know.
 
Thanks.
 
Yale

2040-Post7450.zip (8.55 KB)

Yale, when the map occupies the entire app width, this method works properly. No problem.


But, if you try this approach putting the map on the right side of a grid wpf control with a few columns (in my case, a left pane, a splitter, and the right pane) some issues will occur. In the sample app I provided there's this scenario.



Gustavo,


I am sorry to say that maybe I missed something. I used the sample attached in which I removed the data in data folder attached.
 
I minimized and maximized the control multiple times and it seems works fine. If I am misunderstanding anything, please let me know.
 
Thanks.
 
Yale

2042-ScaleWPF.zip (9.75 KB)