I have something close I think.

My function returns the coordinates that represent a certain tile.  
 From there what you need is to calculate the exact lat/lng position  
within this tile...

It is not exactly what you are asking for and you need to remove some  
stuff, but I just had this file open when I read your email :)

---------
            private function  
getPolygonCoordsFromTileCoords(x:Number,y:Number,zoom:Number):Array {
                  zoom = 17 - zoom;
                      var lon:Number      = -180; // x
                      var lonWidth:Number = 360; // width 360
                      var lat:Number       = -1;
                      var latHeight:Number = 2;
                
                      var tilesAtThisZoom:Number = 1 << (17 - zoom);
                      lonWidth  = 360.0 / tilesAtThisZoom;
                      lon       = -180 + (x * lonWidth);
                      latHeight = -2.0 / tilesAtThisZoom;
                      lat       = 1 + (y * latHeight);
                
                      // convert lat and latHeight to degrees in a transverse  
mercator projection
                      // note that in fact the coordinates go from about -85 to 
+85  
not -90 to 90!
                      latHeight += lat;
                      latHeight = (2 * Math.atan(Math.exp(Math.PI * 
latHeight))) -  
(Math.PI / 2);
                      latHeight *= (180 / Math.PI);
                
                      lat = (2 * Math.atan(Math.exp(Math.PI * lat))) - (Math.PI 
/ 2);
                      lat *= (180 / Math.PI);
                
                      latHeight -= lat;
                
                      if (lonWidth < 0) {
                         lon      = lon + lonWidth;
                         lonWidth = -lonWidth;
                      }
                
                      if (latHeight < 0) {
                         lat       = lat + latHeight;
                         latHeight = -latHeight;
                      }

                      return [
                        new LatLng(lat,lon),
                        new LatLng(lat+latHeight,lon),
                        new LatLng(lat+latHeight,lon+lonWidth),
                        new LatLng(lat,lon+lonWidth),
                        new LatLng(lat,lon)];
            }
-----------


Javier de la Torre
www.vizzuality.com

On Jan 29, 2009, at 12:30 AM, Michael Hansen wrote:

>
> OK, so I have the lat/lng to pixel/tile calcs all worked out.  Anyone
> have the reverse worked out before I go re-invent the wheel?
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" 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-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to