On Dec 4, 2:04 am, scott <[EMAIL PROTECTED]> wrote:
> 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';
> }
>
Looks good.
You may be able to save yourself a few cycles if you do the pixel
computations just once.
pixel=[];
pixel[0]=google
.getCurrentMapType()
.getProjection()
.fromLatLngToPixel(new GLatLng(LL[2],LL[0]),17);
pixel[1]=google
.getCurrentMapType()
.getProjection()
.fromLatLngToPixel(new GLatLng(LL[3],LL[1]),17);
box=[{},{}];
box[0].x=Math.min(pixel[0].x,pixel[1].x);
box[0].y=Math.min(pixel[0].y,pixel[1].y);
box[1].x=Math.max(pixel[0].x,pixel[1].x);
box[1].y=Math.max(pixel[0].y,pixel[1].y);
In your getTileUrl function, you could do the following:
if (box[1].x<(((xy.x+0)<<(25-z))-0)) return "fake tile";
if (box[1].y<(((xy.y+0)<<(25-z))-0)) return "fake tile";
if (box[0].x>(((xy.x+1)<<(25-z))-1)) return "fake tile";
if (box[0].y>(((xy.y+1)<<(25-z))-1)) return "fake tile";
return "real tile";
Also, if you are interested in drawing your rectangle without GPoly,
look at:
www.polyarc.us/boxdiv
> The demo is herehttp://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/)
I looked at it. Very cool.
Perhaps you can help me. I am trying to break the dependency on
Google's "mapsdt" without generating tiles for every zoom level in
every color. I have eight redundant KML files for each state in each
color. I am not aware of a way to do run time binding between KML
files, one with the shapes, another with the colors. Your suggestions
will be welcome.
If I can do it server side on Google's "code" server, I believe it is
the right way to do it. Unfortunately, I am clueless regarding
Google's "code" server. I little example might help a lot.
Thanks very much.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---