diff --git a/composer.json b/composer.json index ac9cf92..4e471a5 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ ], "require": { "php": ">=7.0", - "dantsu/php-image-editor": "^1.2" + "dantsu/php-image-editor": "^1.3" }, "autoload": { "psr-4": { diff --git a/src/TileLayer.php b/src/TileLayer.php index 160ae37..df4a455 100644 --- a/src/TileLayer.php +++ b/src/TileLayer.php @@ -44,17 +44,31 @@ public static function defaultTileLayer(): TileLayer */ protected $opacity = 1; + /** + * @array $curlOptions Array of curl options + */ + protected $curlOptions = []; + + /** + * @bool $failCurlOnError If true, curl will throw an exception on error. + */ + protected $failCurlOnError = false; + /** * TileLayer constructor * @param string $url tile server url with placeholders (`x`, `y`, `z`, `r`, `s`) * @param string $attributionText tile server attribution text * @param string $subdomains tile server subdomains + * @param array $curlOptions Array of curl options + * @param bool $failCurlOnError If true, curl will throw an exception on error. */ - public function __construct(string $url, string $attributionText, string $subdomains = 'abc') + public function __construct(string $url, string $attributionText, string $subdomains = 'abc', array $curlOptions = [], bool $failCurlOnError = false) { $this->url = $url; $this->attributionText = $attributionText; $this->subdomains = \str_split($subdomains); + $this->curlOptions = $curlOptions; + $this->failCurlOnError = $failCurlOnError; } /** @@ -115,7 +129,7 @@ public function getTile(float $x, float $y, int $z): Image return Image::newCanvas(256, 256); } - $tile = Image::fromCurl($this->getTileUrl($x, $y, $z)); + $tile = Image::fromCurl($this->getTileUrl($x, $y, $z),$this->curlOptions, $this->failCurlOnError); if($this->opacity > 0 && $this->opacity < 1) { $tile->setOpacity($this->opacity);