MapImage control improved

Topics: WinForms Controls
May 3, 2007 at 3:05 PM
As you can see here I improved the MapImage control (it's named MapBox, just to avoid to overwrite the old one).
This new control is faster than old one to maps on screen, moreover has a zoom to box and a query on box tools, is faster in panning and zooming (has a nice dynamic zoom too :P) and does not clip the image while panning and zooming (but old method can be selected at design time or run time)... I'm trying to update the old post in the issue section, but seems this site doesn't work ><'... so I decided to post it here... please test it and let me know what you think about it... and if you think any other feature would be good :P
You can download the source file here (let me know if you prefer the full project)
Thanks for your attention and patience ^^

May 7, 2007 at 10:06 AM
Just to let you know I replaced the MapImage control in a project I'm working on with your MapBox control, and it is indeed much faster! And people sure appreciate the mouse-zooming.

I had no trouble building the SharpMap.UI project with the extra sourcefile, and replacing the old control with the new one took maybe 5 minutes.

Great work!
May 7, 2007 at 2:46 PM
Thanks a lot :D
Let me know if there is a feature you would see implemented! ^^
May 9, 2007 at 3:18 PM
I noticed the MapZoomChanged event doesn't fire when zooming with the ZoomWindow tool, maybe it's worth changing the OnMouseUp function a little?

else if (m_ActiveTool == Tools.ZoomWindow)
{
    if (m_Rectangle.Width > 0 && m_Rectangle.Height > 0)
    {
        SharpMap.Geometries.Point lowerLeft;
        SharpMap.Geometries.Point upperRight;
        GetBounds(m_Map.ImageToWorld(m_DragStartPoint), m_Map.ImageToWorld(m_DragEndPoint), out lowerLeft, out upperRight);
 
        m_Map.ZoomToBox(new SharpMap.Geometries.BoundingBox(lowerLeft, upperRight));
    }
}

to

else if (m_ActiveTool == Tools.ZoomWindow)
{
    if (m_Rectangle.Width > 0 && m_Rectangle.Height > 0)
    {
        SharpMap.Geometries.Point lowerLeft;
        SharpMap.Geometries.Point upperRight;
        GetBounds(m_Map.ImageToWorld(m_DragStartPoint), m_Map.ImageToWorld(m_DragEndPoint), out lowerLeft, out upperRight);
 
        m_Map.ZoomToBox(new SharpMap.Geometries.BoundingBox(lowerLeft, upperRight));
 
        if (MapZoomChanged != null)
            MapZoomChanged(m_Map.Zoom);
    }
}

And maybe also fire the MapCenterChanged event?
May 10, 2007 at 2:36 PM
Yes, thanks for pointing out this issue :D
I'll fix this and post the updated file as soon as possible ^^'
May 14, 2007 at 8:39 AM
Edited May 14, 2007 at 8:40 AM
Code has been updated to fire MapCenterChanged and ZoomChanged events.
Latest downloads can be downloaded here.
Thanks again for pointing out this issue :P
Jul 27, 2007 at 8:53 PM

BladeWise wrote:
Code has been updated to fire MapCenterChanged and ZoomChanged events.
Latest downloads can be downloaded here.
Thanks again for pointing out this issue :P


The link is not working... Can you post the file again, please?


Thanks,
George J.
Jul 29, 2007 at 2:32 AM
I'll post a new link on monday with the most update sourcecode :P
Jul 30, 2007 at 8:51 AM
I have posted updated code under the previous URL. It should work now ^^
Jul 30, 2007 at 12:16 PM


BladeWise wrote:
I have posted updated code under the previous URL. It should work now ^^


Yes, thank you!


George J.
Jul 30, 2007 at 12:43 PM
A little help for a VB6 diehard please? Only just started on VB2005 because I found SharpMap. I added MapBox as a Form in the SharpMap.UI project, then tried to build, but I get the following error:

Error 19 The type or namespace name 'Powersoft' does not exist in the namespace 'SharpMap' (are you missing an assembly reference?)
File: C:\Documents and Settings\Administrador\Desktop\devstuff\soft\sharpmap\SharpMap-20766\SharpMap.UI\Forms\MapBox.cs
Line: 203
Column: 32
Project; SharpMap.UI

I tried with the 0.9 source and also with a very recent source. Perhaps MapBox is meant for the Sharmap 2.0 line?
Any help would be appreciated.
Jul 30, 2007 at 3:32 PM
Edited Jul 30, 2007 at 3:32 PM
If you change the string "SharpMap.Powersoft.Forms.MapBox.HighlightModes.None" on the code to "SharpMap.Forms.MapBox.HighlightModes.None" it seems to compile successfully.
Jul 30, 2007 at 5:10 PM
Thanks a lot, that got it working. Already replaced the mapimage component and testing.
Jul 31, 2007 at 8:31 AM
Very nice work, BladeWise. Much improved rendering smoothness particularly when panning.

One minor point though. I would suggest reversing the current assignment of zoom-unzoom order to the mousewheel event. As a longtime Google Earth user, it feels slightly counter-intuitive to roll the wheel back in order to zoom in and vice-versa.

Other than that, a great and much appreciated piece of work.
Jul 31, 2007 at 10:36 AM
Something else.... With the standard MapImage control, I have some code executing on the "Paint" event in order to draw some extra graphics on top of the map. (The code can only be placed at the Point event because it relies on PaintEventArgs-type arguments). Now, using the MapBox control, the Paint event is not firing on my code. I assume this is because you override the OnPaint method in order to provide the rendering improvements of MapBox.

The question is, how can I instruct the control to perform its OnPaint override but also do my own stuff afterwards? Theoretically, I suppose I could stick my extra code at the end of the OnPaint override on the source code, but as I am referencing it from an external DLL that would complicate things (the assembly would need to be aware of various variables on my main application in order to do the relevant rendering).
Jul 31, 2007 at 11:42 AM
Edited Jul 31, 2007 at 11:44 AM
Sorry for late answer :P
First of all, sorry for not reneaming the namespace >< to keep the SharpMap library clean I placed the new code in a separate assembly and forgot to change it!
About Zoom, I think I'll put an enum among properties to change the behave (I like it reversed :P)
Finally about the OnPaint, it's my fault for not calling the base method at the end of the override (or at beginning, it depends if you want to call the event before or after my painting method).

By the way, I updated the code and solved the issues, same location :P (I decided to place the base method call at the end of the OnPaint).

The only thing I'm a bit disappointed is that I had to make the highlight disappear on zoom, or select because some problems of transparecy ><, anyone willing to change and fix it will have my gratitude (too busy with my thesis to work on it atm :( )
Jul 31, 2007 at 1:52 PM
Edited Jul 31, 2007 at 2:04 PM
That did the trick, on both counts. Thanks again!
Jul 31, 2007 at 2:09 PM
Dang, that's too bad about the zoom box highlight, it sure looked good! I agree with Dimitris about the wheel zoom direction, it's good to have a way to reverse this. Great work BladeWise.