ThinkGeo.com    |     Documentation    |     Premium Support

WpfMap Dragging

Hey


So far i'm loving the new architecture... but hitting a few snags (as the number of my posts indicates :P). Here's another...


Using the WpfMap control, when I drag the map using the mouse, it doesn't stay confined to the map control area... and I can drag it around my application. Does anyone have an idea how I can constrain the map to a certain area of the map?


FYI... in the "During Drag" image attached, the screen grab won't capture the mouse, so that's why you don't see it.


 


Before Drag:



 


During Drag




Brendan, 
  
 Thanks for the 1st wpf post! :) It seems an intesting problem and we will give you some response tomorrow.  
  
 Ben.

Thanks Ben. 
  
 I definitely see the future of this control lying in WPF. Once you get into WPF, the possibilities really do become endless. So far, very little of WPF’s abilities have crept into the WpfMap control (for obvious reasons). I’m looking forward to seeing this control develop into something truly amazing. 
  
 Something off the top of my head that would be great (and we should be able to do once the control behaves and leaves the map in the constrained area… hence this post), is to allow smooth rotation without refresh, just by applying a rotate transform (+/- 3 lines of XAML). You wouldn’t need to change a thing on the control. 
  
 The door really is open here.

Brendan, 
  
 We have recreated this issue and we will work on it. Thanks very much for report that. 
  
 Ben  


Great. Thanks.

Brendan, 
  
   I wanted to address your comments on map rotation.  I too was once bright eyed and full of optimism about map rotation.  Now I am older, jaded, and wander the halls of the office muttering “If it were only that simple…” over and over again.  All kidding aside I wanted to talk about some of the challenges of map rotation at a high level. 
  
   The first is that lets image we treated the map as an image and simple rotated that image, sound simple enough right?  Well the first side effect is that there will be gaps where the square image was rotated and no data remains.  This would mean we have to re-fetch the data again and lose some speed in re-drawing and fetching.  One solution would be to draw the image larger than the visible screen area but that effects performance even though we are not sure they ever will rotate. 
  
   The second issue is labeling.  When the map rotates it’s fine to see the streets rotated but people want to maintain the horizontal positioning of the labels.  This means re-rending them as well which causes more work, meaning processing time and not silky smooth rotation.  It also means that we need to calculate the labels as if they were not rotated but the underlying images as if they were.  More trouble for everyone. 
  
   The third issue is that we have to maintain a coherent coordinate system.  Meaning that we need to internally keep track that you have rotated and what that means for things like track zooming, panning, clicking etc.  One sub issue of that is that most spatial indexes are based on straight rectangles.  Straight rectangles have the lower two point on the same x axis.  If you rotate a map at say 10 degrees and then draw a rectangle the “corrected” rectangle once it is rotated back is no longer a straight rectangle.  The conversion between the rotated coordinate system and the true coordinate system because so complex that you can’t imagine.  This is why in our current implementation rotation is considered a projection so that we can internally keep everything coherent.  Using rotation as a map projection means the data can all flow through our framework as a projection and there are certain universal rules we can use to maintain our sanity internally.  Image if you had a rotated and projected map, oh what fun. 
  
 The fourth issue is that with WPF the transform is relatively slow if we do it through XAML.  It seems like XAML is the new HTML/CSS for desktop forms and I think it is great for that.  For too long web developers had a leg up on making nice looking guis and it left us desktop people in the dust.  Of course I prefer desktop apps because of the power you have and when I do web apps I always have to work around the framework to try and make it act more like a desktop app.  I could write a whole book on how web development is screwed up and how they could fix it but that’s for another time.  To get back to my point it seems like XAML wasn’t really designed for heavy graphical drawing on 2D surfaces.  I hope Microsoft puts more attention to this and we can finally discard the GDI+ API.  For year leading up to WPF I played with Avalon and all the betas and CTP hoping that it would get faster but in the end what they shipped was disappointing to me for my purposes. 
  
   I think in summary is that we can’t only look at the map as some items drawing but they need to adhere to certain GIS principles and the data being drawn and its relationship to a world coordinate system is sometime more important than their representation. 
  
 If you actually read this far I have to ask you for a favor.  Could you respond to this post event if to say just “ok”.  We tie our discussion forum to an internal system and if a staff member responds last then the system will mark it as closed.  So by you responding it will keep it open so Ben can answer your other issue.     
  
 David

Thanks for the detailed response to this David. 
  
 Being bushy tailed, we’re going to do a little playing around to see what we can come up with. I’m not yet convinced that this is an insurmountable task. I think that with some sneaky use of Binding, we should be able to overcome all the restrictions you mentioned above (bar the rendering of shapes with many thousands of points (i.e world maps)… which I agree is still the best done in GDI+ for the time being). Either way, I will post back with our findings tomorrow hopefully. 
  
 Take care.

Hey David. 
  
 We took a crack at Map Rotation using WPF. I’ve emailed the solution to support and asked them to forward it to you. Please keep an eye out for it. I didn’t really want to post it here. If anyone else needs it, they can ask here, or mail me. 
  
 Take care

Brendan, 
  
 David is on vocation. he might not give you response these days. Could you also send the solution to me as I’m  interested with the WPF rotation too. You can still send to support@thinkgeo.com and ask to forward to me. 
  
 Thanks in advance. 
  
 Ben

Ben, the email should reach support in the next few minutes.

Thanks! Great!

Got your stuff, Thanks Very much!