Oh, that code will still leave you with negative coordinates.

var numTiles = 1 << zoom;
var wrappedX = coord.x % numTiles;
wrappedX = wrappedX >= 0 ? wrappedX : wrappedX + numTiles;

On Tue, May 31, 2011 at 10:34 PM, Chris Broadfoot <[email protected]> wrote:

> You'll want to wrap the x coordinate. Assuming you're using the default
> projection, you can calculate the number of tiles horizontally across the
> earth at a particular zoom level with:
> 1 << zoom
> or
> Math.pow(2, zoom)
>
> Then use the mod operator. Something like:
> {
>   getTileUrl: function(coord, zoom) {
>     var wrappedX = coord.x % (1 << zoom);
>     return "/tiles/" + zoom + "/" + wrappedX + "/" + coord.y;
>   },
>   tileSize: ...
> ...
> }
>
> BTW - you may want to take a look at the ImageMapType. Seems like it does
> pretty much what you're doing right now.
>
> The above code is untested, but should work!
>
> Chris
>
> --
> http://twitter.com/broady
>



-- 
http://twitter.com/broady

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.

Reply via email to