How to pan a geograpical map

How to pan a geograpical map

I'm developing a map display system. While zoomed in to a certain part of the map I would like to be able to use the mouse to "grab" the image and move it around. When the left mouse button is released the program would then fill in the newly exposed parts of the map. This is routine in proprietory systems of this type, but I don't even know what keywords to start researching in the online help. Does anyone know how to do this? An example?

With many thanks in advance


5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


I don't think your question is appropriate for this forum. How to change the scale in a mapping application or, more general, zoom and panin awindow is not specific for the Fortran language, nor for the CVF or IVF environment. You should consult the textbooks on geometry and computer graphics, or the manual(s) of the basic graphics library (e. g. OpenGL), or the higher-level library (e. g. MapObjectsby ESRI) used byyour mapping program.


There are several areas of this rather high level question that I might be able to help you with, although I'll ask a few questions first.
1. How big are the maps?
2. What machine do you want this to run on?
3. How "snappy" do you want the system to appear?

I ask these because I have developed a viewer for large medical images that does what you want. However, large medical images are 20-80MB of data, where maps can be as large as 1-10GB. Using QuickWin for the image display and Win32 for the GUI, my application was marginally painful on a 500MHz PIII with my images. If you are anywhere near the later size and want snappy performance, you are going to have to write a much lower level (i.e., with C or assembly elements) and much more involved (highly multithreaded, display double-buffered, etc.) application than the one I wrote.

Give us a little more insight into the problem and perhaps some of us will have constructive suggestions.


Once you have the scrolling right, adding panning is easy. I forgot your environment (pure Win32 API if I recall correctly?) but here's a pseudo-code for illustration:

   if (PANNING_MODE) then
      iOrigMouseX = MouseX
      iOrigMouseY = MouseY
      iOrigScrollX = GetScrollPos(SB_HORZ)
      iOrigScrollY = GetScrollPos(SB_VERT)
   end if
   if (PANNING_MODE .and. Left_button_pressed) then
      call ClientCoordToMapCoord(MouseX, MouseY, iX1, iY1)
      call ClientCoordToMapCoord(iOrigMouseX, iOrigMouseY, iX2, iY2)
      SetScrollPos(SB_HORZ, iOrigScrollX + iX2 - iX1)
      SetScrollPos(SB_VERT, iOrigScrollY + iY2 - iY1)
      call Redraw()  ! Redraw on the basis of new scroll pos
   end if

I abstracted some of the code, as your setup is probably different; your "ClientCoordToMapCoord" routine should convert client (mouse) coordinates to whatever coordinate system your map is expressed in, taking into account scrollbar offsets and eventual scaling; I assumed that scrollbar measures these map coordinates rather than pixels. I assume you have something like "ClientCoordToMapCoord"? Jugoslav

Hi Guys,

Thanks for the replies. My question was obviously too vague - I don't need help with calculating geographical coordinates etc, that's easy, it was just the method of "grabbing" the displayed image I had no idea about. Thanks to Jugoslav once again, you have told me exactly what I needed to know.



Leave a Comment

Please sign in to add a comment. Not a member? Join today