Bratliff, it all makes sense and it seems to work, but there is one small detail that bothers me. This is the link: http://my-test.dreamhosters.com/gmap.html
I've implemented the logic as described in this thread and seem to be getting the correct results, but they are still slightly different from what gmap is doing. For example, this is what you'll see when you load the map above: -192x-39; window 500x300; up-left 773x1642 and down-right 776x1644 http://mt3.google.com/vt/v=ap.106&hl=en&x=773&y=1641&z=12&s= http://mt1.google.com/vt/v=ap.106&hl=en&x=773&y=1642&z=12&s=G http://mt3.google.com/vt/v=ap.106&hl=en&x=773&y=1643&z=12&s=Ga http://mt0.google.com/vt/v=ap.106&hl=en&x=774&y=1641&z=12&s=Gal http://mt2.google.com/vt/v=ap.106&hl=en&x=774&y=1642&z=12&s=Gali http://mt0.google.com/vt/v=ap.106&hl=en&x=774&y=1643&z=12&s=Galil http://mt1.google.com/vt/v=ap.106&hl=en&x=775&y=1641&z=12&s=Galile http://mt3.google.com/vt/v=ap.106&hl=en&x=775&y=1642&z=12&s=Galileo http://mt1.google.com/vt/v=ap.106&hl=en&x=775&y=1643&z=12&s= http://mt2.google.com/vt/v=ap.106&hl=en&x=776&y=1641&z=12&s=G http://mt0.google.com/vt/v=ap.106&hl=en&x=776&y=1642&z=12&s=Ga http://mt2.google.com/vt/v=ap.106&hl=en&x=776&y=1643&z=12&s=Gal As you can see, I calculated tiles 773-776 and 1642-1644, but gmap is loading tiles 773-776 and 1641-1643. The result is going to be similar if you move the map. Why is there a one tile difference? There doesn't seem to be any mistake in the calculation and if you look at left/top offset for a particular tile (for example, 773x1642), they are the same between what gmap and I calculated. Should I simply ignore the difference or is there a bug in my calculations? > In my opinion, using DOM listeners is a mistake. Digging through the > DOM may not be legal. Regardless, it is slow and error prone. I agree; I wasn't thinking about doing "first-child of first-child of #map element", but rather something similar to what I have in the script ($("#map img[src*='google.com']")) with something like LiveQuery. I think it's more robust and doesn't require DOM 2 support. Still, your method is probably simpler. Paul. On Aug 30, 5:00 am, bratliff <[email protected]> wrote: > In V2, you can use the "redraw" method of GOverlay. In V3, you will > have to add a "bounds-changed" event listener on the map. I have > asked Google to provide a method similar to "redraw" for OverlayView > but it was rejected. > > Calculate the tile number for the left/right & upper/lower edges of > the visible part of the container DIV. I have found "clientWidth" & > "clientHeight" to be more reliable than using the "getSouthWest(") & > "getNorthEast()" methods. > > The extreme pixels are: > > x0=centerXpixel - ((div.clientWidth+1)>>1) > x1=centerXpixel + ((div.clientWidth+1)>>1) > y0=centerYpixel - ((div.clientHeight+1)>>1) > y1=centerYpixel + ((div.clientHeight+1)>>1) > > the extra pixel is to compensate for truncation if the width or height > are odd numbers. > > The extreme tiles are: > > X0=x0>>8 > X1=((x1-1)>>8)+1 > Y0=y0>>8 > Y1=((y1-1)>>8)+1 > > If the extreme tiles have not changed since the previous "redraw", do > nothing. Otherwise, shuffle tiles. One way is to replace tiles is > with a "removeChild" / "appendChild" sequence. Another way is to > recycle the same tiles. > > You do not have to add "moveend" and "zoomend" event listeners because > you can catch everything important in the "redraw" method. You will > ignore everything unless X0 or X1 or Y0 or Y1 has changed. > > Look at the "redraw" function of: > > www.polyarc.us/sparsetile.js > > It lacks a couple of bug fixes. It still uses the "getSouthWest()" & > "getNorthEast()" methods which may produce erroneous results. It also > produces incorrect tile numbers near the International Date Line. It > is superceded by: > > www.polyarc.us/polycluster.js > > where the tile replacement function is less obvious. > > In my opinion, using DOM listeners is a mistake. Digging through the > DOM may not be legal. Regardless, it is slow and error prone. > > Google has already changed the DOM structure for V3 a couple of times > in the past month. Each tile is contained in its own DIV. > Previously, each tile shared the same parent. The "overlay" panes are > above the tiles in the DOM. Previously, the "overlay" panes were > below the tiles in the DOM. The "z-index" values are the same but the > DOM placement has changed. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
