I was wondering if anyone had any code or direction on how to develop something similar to google maps, where as you zoom closer the large single earth image is replaced with more detailed (high res) maps of the currently zoomed area...and the deeper you go the more detailed the maps become.

So, as in the example above, I have 1 map texture for the overall zoomed out map view, then I break the map into quadrants (or something similar) and have higher res maps for those quadrants, and based on the zoom level I have currently I would swap out the map image with the tiles and still be correctly zoomed over the correct point above the map.

I think I understand this, but I don't know the best way of going about the replacing of the image....the easiest test solution would probably be simply to replace the entire image I currently have with one of the higher resolution, but obviously it would be a waste to draw the parts that are not visible, so how do I go replace just the section that I'm zoomed over....it it fairly simple? Do I just drawImage while specifying the x,y coordinates and width/height and is it that simple?

I'm just thinking that this has to be harder that I'm describing...anyone do this before? it it hard?

Just a thought, if you are going to use PNG for your images, I believe the format allows partial image decompression. i.e. say you have a 3000x3000 image saved as a PNG, you can "load" only a sub section of the PNG, lets say 640x480 at location 400,600. This will mean that you do not need to decompress the entire image in to memory and will save having to have pre-cut tile images.

This means you need only have as many images as you have zoom levels. (of course these images will increase in dimensions as you increase in zoom)

You may need to research to find a PNG loader for java which allows you to do this.

Just a thought, if you are going to use PNG for your images, I believe the format allows partial image decompression. i.e. say you have a 3000x3000 image saved as a PNG, you can "load" only a sub section of the PNG, lets say 640x480 at location 400,600. This will mean that you do not need to decompress the entire image in to memory and will save having to have pre-cut tile images.

This means you need only have as many images as you have zoom levels. (of course these images will increase in dimensions as you increase in zoom)

You may need to research to find a PNG loader for java which allows you to do this.

Interesting, I was not aware of this, thanks. I was not planning on using PNG images at the moment, though I guess they can be converted to that format.

I might have to use that if I can't figure out the tiling with zooming. I'll still try to pursue the tiling option as that has been of interest to me for a while, but now I actually need a solution for the map tool I'm making. The biggest question that I have so far is how to do the zooming properly. Currently I have one image, and this images gets scaled by the zoom factor and so as you get closer you get a more grainy/blurry image - obviously. With the zooming and tiling (or whatever it is called) you initially would still scale your image until you reached the appropriate threshold at which point you replace the current image with the composite of higher resolution images, but at that point I think you have to clear your scale factor because you would effectively be doing double scaling: first scaling via scaling factor, and second scaling because you swapped to higher resolution images...does that sound right?

I've got some code that you could modify to do something like what google maps does.

I'm making a top-view down game where I use tiled images as a back-buffer which I draw other images and effects onto, these tiles form the map. As the player moves to the left, the tiles on the right which are not on the screen anymore are recycled and moved to the left where they are needed. These recycled tiles are re-painted appropriately.

Currently if you zoom in, the tiles are zoomed into as well, so there are fewer tiles visible on the screen. If you zoom out, then the tiles are zoomed out too and you need more tiles on the screen.

A little off centre, but I have had the thought that instead of "blurring" when zooming, how about a total paradigm shift?

Instead of having discrete sets of tiles at different levels of zoom, why not generate mathematical models of how the pixels from the highest resolution (zoomed in) image progressively merge as you zoom out. In this fashion you will achive very little burring and you can have an arbitrary zoom level.

I am thinking that using Least Mean Squares to generate equations to produce the mathematical model of how the pixels merge. To do this I would start with the highest resoultion image and the progressively resize the image, say by 10% each time, generating a list of samples corresponding to each original image corordinate. The least Mean Squares would use each list of samples to generate a function which approximates the list.

This way, all you need to do is to do generate a zoomed image is something like:

where offsetX,offsetY are offsets on the original high res image representing the current view image offsets.multiplier is used in conjunction with the x and y coordiantes of the zoomed image being created to reference the correct model.The zoom is a value between 0 and 1 where 0 is the max zoomed in image and 1 is the max zoomed out image.

But you are talking about going backwards in the zooming...from the highest resolution image to the lowest. Though you only have one image to start with, it is a huge image. The purpose of the tiling approach is to load only the images that you want and as you zoom closer and closer you are only loading or retrieving from a cache the data that you want.

For the creation of the functions which will represent the model the zooming will happen in reverse. This can and should be precomputed.

You do not need to know all the functions at runtime. You need only request the relevant functions to produce at image at a given zoom, so even if you do not cache the functions locally, for each zoom the max number of functions to request is img_width*img_height. With caching of the functions the number that you need to request decreases.

Your program can choose an arbitrary zoom or if you know your program can only zoom in and out then you can pre-fetch functions which could be used.

You should create quad-tree. Start off with a node containing the whole map (earth) at 256x256. Then split the node up recursively. One split will replace one 256x256 image with 4 256x256 images. When you move you may need to merge nodes as well. Kind of a bad explanation, but if you google for it you should get plenty of hits.

I made mandelbrot zoomer that uses this method. I've attached the code (it's a zip file, extract to get the code). It uses java3D and I also think there is a Java2D version.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org