User:Thraxis Epsilon/map api

From Second Life Wiki
Jump to navigation Jump to search


To define a better Web Map API that follows pre-existing standards and allows for use without restrictions that the current implementation has.

Problems with the current system

The current Web Map API has several issues. The first is the reliance on the Google API. This requires an API key and ties the map to a specific domain. Also the tile system designed for this purpose does not match the Second Life tile layout. The region "Da Boom" is at tile position 1000,1000 in the SL map. Yet the tile service identifies this tile as 1000,279.

This translation will cause a problem for any map tile that exists at a co-ordinate with a Y value greater then 1280 (there are a few regions already at this location)

Proposed Solution

The tile system should retain a one to one parity with the SL co-ordinate system. To do this using the TMS (Tile Map Service) Specification

I built a PHP translation layer to translate TMS calls to SL Map API calls:

<php> <? $temp1 = str_replace(".jpg", "", $_SERVER['PHP_SELF']); $temp1 = str_replace("/", "|", $temp1 ); $temp = explode("|",$temp1);

$zoom = 7 - $temp[3]; $factor = pow(2,$zoom-1); $y = (1280/$factor)-$temp[5] - 1;

if ($temp[2] == "overlay") { $layer = 1; } if ($temp[2] == "map") { $layer = 0; } header( 'Location:'.$temp[4].'-'.$y.'-'.$zoom.'-'.$layer.'.htm' ) ; ?> </php>

This translates calls in the following format: To the SL Map Tile server format of:

For testing this works rather well and the result, using the OpenLayers API can be seen at Example Map

NOTE: The example listed is also using a partial wrapper to translate SL Map API calls to OpenLayers