User:Kerik Rau/MapTileURL

From Second Life Wiki
< User:Kerik Rau
Revision as of 14:35, 16 January 2009 by Kerik Rau (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Returns the URL of the image of the current sim's tile (a 256x256 pixel image). Also see Thraxis Epsilon's OpenLayers Wrapper.

<lsl> string MapTileURL() {

   vector TilePos = llGetRegionCorner();

   //tiles are in a grid based on the regions, so 256m = 1 tile
   TilePos /= 256.0;
   
   //offset provided in the javascript, really 1278 + 1 (probably 0 -> 1 index difference?)
   TilePos.y = 1279.0 - TilePos.y;
   
   //should look like http://secondlife.com/apps/mapapi/grid/map_image/x-y-zoom-0
   string mapURL = "http://secondlife.com/apps/mapapi/grid/map_image/";
   mapURL += (string) llFloor(TilePos.x);
   mapURL += "-";
   mapURL += (string) llFloor(TilePos.y);

   //the 3rd value is something to do with zoom
   mapURL += "-1-0";
   return mapURL;

} </lsl>