@@ -44,17 +44,31 @@ public static function defaultTileLayer(): TileLayer
4444 */
4545 protected $ opacity = 1 ;
4646
47+ /**
48+ * @array $curlOptions Array of curl options
49+ */
50+ protected $ curlOptions = [];
51+
52+ /**
53+ * @bool $failCurlOnError If true, curl will throw an exception on error.
54+ */
55+ protected $ failCurlOnError = false ;
56+
4757 /**
4858 * TileLayer constructor
4959 * @param string $url tile server url with placeholders (`x`, `y`, `z`, `r`, `s`)
5060 * @param string $attributionText tile server attribution text
5161 * @param string $subdomains tile server subdomains
62+ * @param array $curlOptions Array of curl options
63+ * @param bool $failCurlOnError If true, curl will throw an exception on error.
5264 */
53- public function __construct (string $ url , string $ attributionText , string $ subdomains = 'abc ' )
65+ public function __construct (string $ url , string $ attributionText , string $ subdomains = 'abc ' , array $ curlOptions = [], bool $ failCurlOnError = false )
5466 {
5567 $ this ->url = $ url ;
5668 $ this ->attributionText = $ attributionText ;
5769 $ this ->subdomains = \str_split ($ subdomains );
70+ $ this ->curlOptions = $ curlOptions ;
71+ $ this ->failCurlOnError = $ failCurlOnError ;
5872 }
5973
6074 /**
@@ -115,7 +129,7 @@ public function getTile(float $x, float $y, int $z): Image
115129 return Image::newCanvas (256 , 256 );
116130 }
117131
118- $ tile = Image::fromCurl ($ this ->getTileUrl ($ x , $ y , $ z ));
132+ $ tile = Image::fromCurl ($ this ->getTileUrl ($ x , $ y , $ z ), $ this -> curlOptions , $ this -> failCurlOnError );
119133
120134 if ($ this ->opacity > 0 && $ this ->opacity < 1 ) {
121135 $ tile ->setOpacity ($ this ->opacity );
0 commit comments