0

I am loading map tiles on a JPanel based on the appropriate zoom level. Everytime I load the tiles for the next or previous zoom levels, I'm trying to create an effect similar to Google Maps where the current map tiles zoom in (or zoom out) and then the map tiles for the subsequent zoom level appears in a transition effect. Is it possible to create such an effect in JPanel? I'm using JMapViewer where the tiles are loaded from my local machine.

I referred the following link but somehow not finding any headway: http://codekea.com/39jNvxn35jyE/free-java-swing-component-to-view-images-with-zoom-scroll-%3E-wanted-closed.html

I was able to create a fade-in effect of the map tiles that loads on zoom in or zoom out using the following link: http://stackoverflow.com/questions/17731576/making-an-image-fade-in-and-fade-out

But when I try to scale and transform the Graphics, the newly loaded tiles gets scaled and transformed but not the previous one. Why is it so?

  • 1
    You need to perform the following steps. 1) Create a new BufferedImage with the zoomed in or zoomed out tiles. 2) Create (or use) a BufferedImage for the existing tiles in the JPanel. 3) Use a scaling transformation to change the BufferedImage of the ** existing tiles**. Display a series of these images as an animation. 4) When the animation is finished, display the BufferedImage from 1) on the JPanel. – Gilbert Le Blanc Sep 11 '15 at 21:38
  • How do you create a single Buffered Image of multiple tiles in the JPanel? – suhas bhairav Sep 11 '15 at 21:40
  • 1
    You build a BufferedImage from the tiles, and display the BufferedImage in the JPanel. Each tile is 256 x 256 pixels. If your display is 800 x 600, you build a BufferedImage of 4 tiles x 3 tiles, or 1024 X 768 pixels. As you move east or west, you add 3 tiles to the right edge or left edge, respectively, and drop the 3 tiles from the opposite edge. You do the same for north or south movement, except you add 4 tiles to the top edge or bottom edge, respectively. and drop the 4 tiles from the opposite edge. – Gilbert Le Blanc Sep 11 '15 at 21:44

0 Answers0