ThinkGeo.com    |     Documentation    |     Premium Support

Map Refresh issues

Hi,


In my application, I have a map (WpfMapControl) with 4 layers:


* RasterLayer


* 2   ShapeFileFeatureLayer


* InMemoryFeatureLayer


Each layer is contained in an overlay of its own.


The InMemoryFeatureLayer contains vehicles information which get updated every few seconds.


I update the vehicles layer using the  EnterWriteLock and ExitWriteLock functions.


After I update the vehicles layer i call  map.Refresh().  As a result the raster layer and the 2 shape file layers disappear and only the vehicle layer is displayed. Once i pan the map, everyhing is diplayed again until the next time.


If , before calling the refresh() , i call the writeLock for the other 3 overlays then the refresh works fine but it takes a long time as everything needs to be redrawn.


I would expect the refresh function to redraw all "non dirty" overlays from an internal cache and regenerate the image for the dirty overlay. From what i see,  the non dirty overlays do not get redrawn at all.


 



Ofer,


Thanks for your post.
 
Just want to make sure which version of Desktop Edition are your trying to use now? If you are using last public release 3.0.426 and use the default threading mode, then just forget about the lock stuff, what you need do is call refresh and pass in the target overlay to be redraw,  shown as following:

winformsMap1.Refresh(vehicleInmemoryFeatureOverlay);

 
Any more quesitons just feel free to let me know.

 
Thanks.
 
Yale


Yale,


Thanks, it seems to work now but i have a few questions:


What is the default threading mode? is it single, multi or something else?


What are the differences between the threading modes and their pros and cons


is the lock stuff deprecated? are there situations or modes where you have to use it?


can you explain the logic of whst happens when both versions of map.refresh are being called


 


Thanks.



Ofer, 
  
 I am glad to know you! Let me ask your questions. 
  
 The default threading mode is single thread. 
  
 Single thread is more stable than multi thread, but during map rendering, the control is not responsible. 
  
 Multi thread has better user experience; the user can do interactive things continuously even the map is still rendering. 
  
 The lock stuff is not deprecated, when your map working under the other thread (not the UI thread) and you have to lock your overlay when you update it. 
  
 Map.Refresh() will draw all overlays, if any overlay has cached image, it will directly use cached image first, if no suitable image then draw image by features. 
  
 Map.Refresh(Overlay) will draw specific overlay, it will ignore overlay’s cache image, draw image by features whatever. 
  
  
 Please let me know if my description is not clear. 
 Thanks. 
  
 James 


James,


can you explain "but during map rendering, the control is not responsible"


In multi threaded mode do you assign tasks such as refresh to other threads that you create?


Can you look at the problem i described at the begining of this thread (I was working in multi threading mode) and let me know if i was doing anything wrong?


Thanks,


Ofer



Ofer, 
  
   I can help explain.  For the first point what he meant to write was unresponsive, meaning since we have everything on one thread the UI does not respond while we are drawing the map. 
  
 In multi-threaded mode we do create some new threads to draw in the background so that the UI thread remains responsive.  This is why we need for you to call the locking code as you might change something from the UI thread about the layer while the layer is drawing on another thread and the results if the locking is not done properly is very bad. 
  
 I looked back at your comments and I think they are valid.  The issue I think is the evolution of the API over the betas.  A few version ago we have the IsDirty flag on the lock object and it was set by exiting a lock.  When you called refresh if only re-drew overlays where the IsDirty was true and the other overlays used their cached version to make it fast.  Then we changed the way we did the drawing and we added overloads to the refresh method so that single threaded people can also refresh one overlay at a time without going to the lock object.  I think when we did that it made the IsDirty no longer relevant.  I agree that it should know based on the exit write lock but we kinda decided to go with what was in the refresh method otherwise we could have conflicting thoughts.  One overlay is dirty but the user called the refresh specify another overlay.  At that point we are in a little conundrum.   
  
   In the end I think the code we posted a few posts up is what you need.  if you use multi-threading still do the locks and when you refresh use the refresh overload to specify the overlays you want to update.  We are moving away from the IsDirty and want everyone to use the overloads. 
  
 I hope this helps. 
  
 David 
  


I submitted a ticket for this same issue. I'll post another comment there. It seems to me that map.Refresh() is now broken. If you're moving away from this functionality, I think you should mark the Refresh method as deprecated so that we're aware that there are now issues with it. By using the overlay specific refresh, I now have most everything working except for when I pan, if I have other layers loaded, the google map portion (my base layer) disappears. It will reappear after some number of seconds that is dependent on the number of additional layers loaded. If it's 1 additionaly layer (SQL), it's about 8 seconds and the time goes up from there. What's weird to me about this is that the icons for the SQL layer appear almost immediately, but it takes the google portion of the map a long time to appear. This slowness of the maps appears even on a section of the map I was just viewing a few seconds before.



Kimberly,


Thanks for your post and suggestions.
 
I am wondering this problem is caused for the slowness (for example, bad network etc) of the Google Layer in your environment.
 
1) .Can you try to load only a Google layer to see its performance without any other layers added?
 
2) When you add 2 layers (Google Layer and Sql Layer), could you try setting the cache directory to see its performance after it is cached?

googleLayer.CacheDirectory = @"C:\temp"; 

 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale