diff --git a/README.md b/README.md index 638bf43..a75cbe4 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ This software should make it simple to use pre-rendered map tiles in your own pr Download project files and upload it into your web hosting of your choice. -Open the **"proxy-test.html"** within your browser, your proxy server should display you a simple slippy maps rendering default Open Street Map tiles. -Or test directly in your browser with a tile URL such as: http://www.example.com/tiles/15/17024/10792.png +Open the **"test.html"** file within your browser, your proxy server should display you a simple slippy maps rendering default Open Street Map tiles. +Or test directly in your browser with a tile URL such as: http://www.example.com/tiles/15/17024/10792.png **NB.** Remeber to check your web server folder permissions: **777** or **755** @@ -36,7 +36,7 @@ Or test directly in your browser with a tile URL such as: http://www.example.co $tiles_config['servers'] = array( 'osm' => 'https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'otm' => 'https://{switch:a,b,c}.tile.opentopomap.org/{z}/{x}/{y}.png', - // ADD: more services here + // ADD: more services here. ); /** @@ -52,7 +52,7 @@ Or test directly in your browser with a tile URL such as: http://www.example.co * @var string */ // CHANGE: bounding box cache-area to fit your own needs - $tiles_config['bbox'] = '6.602696,35.07638,19.12499,47.10169'; // Italy tiles are cached, others are proxied! + $tiles_config['bbox'] = '6.602696,35.07638,19.12499,47.10169'; // CHANGE: bbox tiles (Italy) are cached, others are proxied! /** * Cache timeout in seconds @@ -76,7 +76,7 @@ Or test directly in your browser with a tile URL such as: http://www.example.co ``` 2. **create your first simple “tile-proxy-php” slippy map** - + a. **_include CSS & JavaScript_** ```html
@@ -87,7 +87,7 @@ Or test directly in your browser with a tile URL such as: http://www.example.co ... ``` - + a. **_choose the div container used for the slippy map_** ```html @@ -105,9 +105,9 @@ Or test directly in your browser with a tile URL such as: http://www.example.co var tms_id = 'otm'; var tileLayer = L.tileLayer(proxy_url, { - attribution: 'map data: © OpenStreetMap contributors, ' + - 'SRTM | ' + - 'map style: © OpenTopoMap ' + + attribution: 'map data: © OpenStreetMap contributors, ' + + 'SRTM | ' + + 'map style: © OpenTopoMap ' + '(CC-BY-SA), ', id: tms_id }); diff --git a/config.php b/config.php index f32bbbf..85c49f5 100644 --- a/config.php +++ b/config.php @@ -11,11 +11,14 @@ /** * Whitelist of supported tile servers * + * @link https://wiki.openstreetmap.org/wiki/Tile_servers + * * @var array */ -$tiles_config['servers'] = array( - 'osm' => 'https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png', - 'otm' => 'https://{switch:a,b,c}.tile.opentopomap.org/{z}/{x}/{y}.png', +$config['servers'] = array( + 'osm' => 'https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png', + 'otm' => 'https://{switch:a,b,c}.tile.opentopomap.org/{z}/{x}/{y}.png', + // ADD: more services here. ); /** @@ -30,7 +33,7 @@ $tiles_config['servers'] = array( * * @var string */ -$tiles_config['bbox'] = '6.602696,35.07638,19.12499,47.10169'; // Italy. +$config['bbox'] = '6.602696,35.07638,19.12499,47.10169'; // CHANGE: bbox tiles (Italy) are cached, others are proxied! /** * Cache timeout in seconds @@ -41,13 +44,13 @@ $tiles_config['bbox'] = '6.602696,35.07638,19.12499,47.10169'; // Italy. * * @var int */ -$tiles_config['ttl'] = 86400; +$config['ttl'] = 86400; /** * Custom Proxy Server headers * * @var string */ -$tiles_config['headers'] = array( +$config['headers'] = array( 'Access-Control-Allow-Origin:' => '*', ); diff --git a/index.php b/index.php index e3cbf9d..02eb2a7 100644 --- a/index.php +++ b/index.php @@ -15,18 +15,20 @@ * @license https://www.gnu.org/licenses/gpl-3.0.txt GNU/GPLv3 */ +// TODO: code refactoring ( wrap it within a dedicated class.. ) + // User configs. require_once 'config.php'; // Default configs. -$servers = @$tiles_config['servers'] ?: array( +$servers = @$config['servers'] ?: array( 'osm' => 'https://{switch:a,b,c}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'otm' => 'https://{switch:a,b,c}.tile.opentopomap.org/{z}/{x}/{y}.png', ); -$bbox = @$tiles_config['bbox'] ?: '-180,-90,180,90'; -$ttl = @$tiles_config['ttl'] ?: 86400; +$bbox = @$config['bbox'] ?: '-180,-90,180,90'; +$ttl = @$config['ttl'] ?: 86400; $headers = array_change_key_case( - @$tiles_config['headers'] ?: array( + @$config['headers'] ?: array( 'Access-Control-Allow-Origin:' => '*', ), CASE_LOWER ); diff --git a/proxy-test.html b/test.html similarity index 100% rename from proxy-test.html rename to test.html