ThinkGeo.com    |     Documentation    |     Premium Support

Some events do not fire & How to use e.NativeImage?

Hi.


1. I found that some events in WinformsMap do not fire. Please check them.


- LayerDrawing


- OverlaysDrawing


 


2. I tried to use NativeImage property in OverlayDrawingEventArgs.


[private void map_OverlayDrawing(object sender, ThinkGeo.MapSuite.DesktopEdition.OverlayDrawingEventArgs e)]


But the size of the NativeImage bitmap is different from the size of the map control. Why is it like this? and How can I get the exact visible region in the map control? What I want to do is drawing graphics with GDI+, and I want to avoid making a custom layer.


            Bitmap b = (Bitmap)e.NativeImage;

            Graphics g = Graphics.FromImage(b);

            Console.WriteLine("Width {0} Height {1}", b.Width, b.Height);

 


3. what's the difference between OverlayDrawing event and LayerDrawing event? Could you explain the basic concept of Overlay and Layer?



Seungwoo, 
  
 Thanks for your post. You are right that in the current Beta (3.0.199), the following events cannot be fired: 
 winformsMap1.LayerDrawing 
 winformsMap1.LayerDrawn 
 winformsMap1.OverlaysDrawing 
 winformsMap1.OverlaysDrawn 
  
 And the following 2 events doesn’t work correctly 
 winformsMap1.OverlayDrawing  
 winformsMap1.OverlayDrawn  
  
 Main reason is that as we are trying to tile the images with multi-threading, tiles has much possibilities to be drawn simultaneously which makes it difficult to get which is the last tile drawn and what’s the proper time to raise the events. Those events used to work with the first release when we only have single tile and single threading, but now they are kind of obsolete. We are still trying to make those events work with tiling and multi-threading, hopefully we can have some solution in the next release. 
 About Layer and Overlay, Layer is more related with data and Overlay is more related with the representing. An Overlay is supposed to be a separate image which can be refreshed and cached independently while a layer provides many data related APIs as well as the render style for the data. For example, I have LayerA and LayerB added to OverlayA and LayerC added to OverlayB, if I did any changes on LayerB and want to update the map, I need to update the OverlayA that will refresh both LayerA and LayerB. I cannot only redraw LayerB as an Overlay is the smallest unit for presenting.  I do not need to update OverlayB though in this case as it is independent with OverlayA. In the current version though we cannot just refresh an overlay(except DynamicOverlay), that’s a problem and we will definitely solve it in the future release. 
 Hope that helps, let me know if you have any issues. 
  
 Thanks, 
  
 Ben

Thanks, Ben. 
  
 Could you answer the second question, too? 
  
 :)

Seungwoo,  
  
 As the OverlayDrawing doesn’t work right in the current version, the NativeImage in the event args doesn’t make much sense. Any way, NativeImage is only the map needs to be drawn. For example, I have a map with the size of 600 * 600, if I pan left  with 100 pixels, the new images I need to draw is 100*600, you can see that’s not same with map’s size. 
  
 To get the visible region of the map control, you can simply use the properties winformMap1.Width/Height. And to work around the current issue, creating a custom layer is not a bad idea. It is not that complicated and also easy to use. Why don’t you want to do that? let us know if we can help. 
  
 Thanks, 
  
 Ben