views:

37

answers:

1

Hi,I'm currently implementing logic on custom tile layers via OpenLayers

function getTiles() {
    var res = this.map.getResolution();
    var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
    var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
    var z = this.map.getZoom();
    return ......;
}

What I need to is to carry this code in Google API v3. As I searched documentation I found this code to work with:

var customtile = new google.maps.ImageMapType({
     getTileUrl: function (coord, zoom) {
     ....
     ....
     }

Unfortonately,I cannot convert logic in OpenLayers code to Google.
As I know resolution is
180 * tileSize.w / Math.pow(2, zoom) //where tileSize is 256x256

Since Google projection is same with my tiles WGS84 boundary should be
-180,-90,90,180

I need to calculate to extent coordinates,but in function getTileUrl,there are two arguments.
One of which is zoom,but the other coord is some x,y pair which I dont understand what that is.What is that exactly ?
How can I generalize formula for calculating tile numbers in Google Maps?

Thank you
Myra

A: 

I think its the upper left hand coordinate.

See http://trac.osgeo.org/openlayers/wiki/UsingCustomTiles for more details.

geographika
It's obviously true that coord pair is left hand coordinate.My real problem is to find tile numbers.Do you have a suggestion on formula?
Myra
Your question is a little unclear. You want to find the google tile for a specific x,y point at a specified zoom level?
geographika
No,the tiles are custom not google,I'm trying to find their coordinates in getTileUrl method.
Myra