@bratliff very nice demos
I went ahead and used getTileUrl to provide a method that clips tile
creation to my bounds as follows:
function CustomGetTileUrl(point,zoom)
{
if (zoom > 16)
{
return 'blanktile.png';
}
// Define our tile boundaries
// Note: origin in google maps is top-left
var minLL = new GLatLng(24.67,-81.99);
var maxLL = new GLatLng(24.29,-81.48);
// convert our lat/long values to world pixel coordinates
var currentProjection = G_NORMAL_MAP.getProjection();
var minPixelPt = currentProjection.fromLatLngToPixel(minLL,
zoom);
var maxPixelPt = currentProjection.fromLatLngToPixel(maxLL,
zoom);
// convert our world pixel coordinates to tile coordinates
var minTileCoord = new GPoint();
minTileCoord.x = Math.floor(minPixelPt.x / 256);
minTileCoord.y = Math.floor(minPixelPt.y / 256);
var maxTileCoord = new GPoint();
maxTileCoord.x = Math.floor(maxPixelPt.x / 256);
maxTileCoord.y = Math.floor(maxPixelPt.y / 256);
// filter out any tile requests outside of our bounds
if (point.x < minTileCoord.x ||
point.x > maxTileCoord.x ||
point.y < minTileCoord.y ||
point.y > maxTileCoord.y)
{
return 'blanktile.png';
}
return 'reefs/' + zoom + '/' + point.x + '_' + point.y + '.png';
}
The demo is here http://www.salmonsalvo.net/Cumberland:GoogleMapsTest
(By the way, I am working on an open source project in which one
feature is google maps tile creation (including tile pyramids):
http://code.google.com/p/cumberland/ )
thanks for the help,
Scott
On Dec 3, 5:44 pm, bratliff <[EMAIL PROTECTED]> wrote:
> On Dec 3, 7:00 pm, scott <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi folks,
>
> > I have search the API, but cannot find a way to tell google maps that
> > I only want it to request tiles within a given lat/long boundary. My
> > code is simple:
>
> > var tl = new GTileLayer(null, null, null, {
> > tileUrlTemplate: '/tiles/reefs/{Z}/{X}_{Y}.png',
> > isPng:true,
> > opacity:1.0 });
> > var tileLayerOverlay = new GTileLayerOverlay(tl);
>
> > map.addOverlay(tileLayerOverlay);
>
> > But i only have tiles within a small subset of the world, and would
> > like to prevent unnecessary requests. Is it possible to clip the
> > boundaries of a tile overlay?
>
> > thanks.
> > Scott
>
> Check out Sparse Tile Layer Overlays:
>
> www.polyarc.us/sparsetile.js
>
> Dynamic maps version:
>
> www.polyarc.us/sparse
>
> Static maps version:
>
> www.polyarc.us/poly
>
> Both combine several sparsely populated tile sets into a single
> overlay. It does not require multiple overlays. It does not attempt
> to fetch missing tiles. It is useful for changing the collection of
> tile sets on the fly. The static map version has some improvements
> not made in the dynamic map version.
>
> It can be done also using GTileLayerOverlay for a single set of
> tiles. A template will not work because you cannot apply a bounding
> box. In your "getUrl" method, substitute Google's "transparent.png"
> image for tiles not available from your tile server.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---