On Aug 28, 9:26 pm, Paul Kulchenko <[email protected]> wrote:
Both V2 & V3 provide a "fromLatLngToDivPixel" method. V2 also
provides a "fromLatLngToPixel" method expecting a zoom level. V3 does
not have a "fromLatLngToPixel" method but the arithmetic is fairly
simple for a Mercator projection. It is also quicker to do it
directly if you have to do it repeatedly.
With the two methods, determine the pixel position of the same point.
I like to use the center of the map because it is reliable. The
corners can be unreliable at low numbered zoom levels if the map wraps
around. The X & Y pixel differences are the map offset. It will not
change during dragging but both "setCenter" & "setZoom" will cause it
to be recalculated. Why it was not simply set to zero is unclear to
me. In a home grown tile stitcher I never have to reset it. It is
always zero.
Once you know the global pixel position of the center of the map, you
can determine its top & left tile offsets by shifting both pixel
coordinates:
offsetX=pixelX-(pixelX>>8<<8);
offsetY=pixelY-(pixelY>>8<<8);
The difference between the pixel position & the normalized tile
position is the pixel offset relative the top left of the tile. Every
other tile is positioned some positive or negative multiple of 256
pixels from the center tile. A simple bounds check will determine
which tiles are visable.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---