mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-08-02 20:57:29 +02:00
CORS for tiles.
This commit is contained in:
@@ -261,6 +261,7 @@ class Server {
|
|||||||
public function renderTile($tileset, $z, $y, $x, $ext) {
|
public function renderTile($tileset, $z, $y, $x, $ext) {
|
||||||
if ($this->isDBLayer($tileset)) {
|
if ($this->isDBLayer($tileset)) {
|
||||||
if ($this->isModified($tileset) == TRUE) {
|
if ($this->isModified($tileset) == TRUE) {
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('HTTP/1.1 304 Not Modified');
|
header('HTTP/1.1 304 Not Modified');
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
@@ -283,12 +284,14 @@ class Server {
|
|||||||
if ($format == 'jpg') {
|
if ($format == 'jpg') {
|
||||||
$format = 'jpeg';
|
$format = 'jpeg';
|
||||||
}
|
}
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('Content-type: image/' . $format);
|
header('Content-type: image/' . $format);
|
||||||
echo $data;
|
echo $data;
|
||||||
}
|
}
|
||||||
} elseif ($this->isFileLayer($tileset)) {
|
} elseif ($this->isFileLayer($tileset)) {
|
||||||
$name = './' . $tileset . '/' . $z . '/' . $x . '/' . $y . '.' . $ext;
|
$name = './' . $tileset . '/' . $z . '/' . $x . '/' . $y . '.' . $ext;
|
||||||
if ($fp = @fopen($name, 'rb')) {
|
if ($fp = @fopen($name, 'rb')) {
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('Content-Type: image/' . $ext);
|
header('Content-Type: image/' . $ext);
|
||||||
header('Content-Length: ' . filesize($name));
|
header('Content-Length: ' . filesize($name));
|
||||||
fpassthru($fp);
|
fpassthru($fp);
|
||||||
@@ -310,6 +313,7 @@ class Server {
|
|||||||
imagesavealpha($png, true);
|
imagesavealpha($png, true);
|
||||||
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
|
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
|
||||||
imagefill($png, 0, 0, $trans_colour);
|
imagefill($png, 0, 0, $trans_colour);
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
header('Content-type: image/png');
|
header('Content-type: image/png');
|
||||||
imagepng($png);
|
imagepng($png);
|
||||||
die;
|
die;
|
||||||
|
Reference in New Issue
Block a user