@@ -44,17 +44,31 @@ public static function defaultTileLayer(): TileLayer
44
44
*/
45
45
protected $ opacity = 1 ;
46
46
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
+
47
57
/**
48
58
* TileLayer constructor
49
59
* @param string $url tile server url with placeholders (`x`, `y`, `z`, `r`, `s`)
50
60
* @param string $attributionText tile server attribution text
51
61
* @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.
52
64
*/
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 )
54
66
{
55
67
$ this ->url = $ url ;
56
68
$ this ->attributionText = $ attributionText ;
57
69
$ this ->subdomains = \str_split ($ subdomains );
70
+ $ this ->curlOptions = $ curlOptions ;
71
+ $ this ->failCurlOnError = $ failCurlOnError ;
58
72
}
59
73
60
74
/**
@@ -115,7 +129,7 @@ public function getTile(float $x, float $y, int $z): Image
115
129
return Image::newCanvas (256 , 256 );
116
130
}
117
131
118
- $ tile = Image::fromCurl ($ this ->getTileUrl ($ x , $ y , $ z ));
132
+ $ tile = Image::fromCurl ($ this ->getTileUrl ($ x , $ y , $ z ), $ this -> curlOptions , $ this -> failCurlOnError );
119
133
120
134
if ($ this ->opacity > 0 && $ this ->opacity < 1 ) {
121
135
$ tile ->setOpacity ($ this ->opacity );
0 commit comments