@@ -8,6 +8,7 @@ export class XYZImageSource extends TiledImageSource {
88 const {
99 levels = 20 ,
1010 tileDimension = 256 ,
11+ projection = 'EPSG:4326' ,
1112 url = null ,
1213 ...rest
1314 } = options ;
@@ -16,6 +17,7 @@ export class XYZImageSource extends TiledImageSource {
1617
1718 this . tileDimension = tileDimension ;
1819 this . levels = levels ;
20+ this . projection = projection ;
1921 this . url = url ;
2022
2123 }
@@ -32,15 +34,34 @@ export class XYZImageSource extends TiledImageSource {
3234 init ( ) {
3335
3436 // transform the url
35- const { tiling, tileDimension, levels, url } = this ;
36-
37+ const { tiling, tileDimension, levels, url, projection } = this ;
3738 tiling . flipY = ! / { \s * r e v e r s e Y | - \s * y \s * } / g. test ( url ) ;
38- tiling . setProjection ( new ProjectionScheme ( 'EPSG:3857' ) ) ;
39+ tiling . setProjection ( new ProjectionScheme ( projection ) ) ;
3940 tiling . setContentBounds ( ...tiling . projection . getBounds ( ) ) ;
40- tiling . generateLevels ( levels , tiling . projection . tileCountX , tiling . projection . tileCountY , {
41- tilePixelWidth : tileDimension ,
42- tilePixelHeight : tileDimension ,
43- } ) ;
41+ if ( Array . isArray ( levels ) ) {
42+
43+ levels . forEach ( ( info , level ) => {
44+
45+ if ( info !== null ) {
46+
47+ tiling . setLevel ( level , {
48+ tilePixelWidth : tileDimension ,
49+ tilePixelHeight : tileDimension ,
50+ ...info
51+ } ) ;
52+
53+ }
54+
55+ } ) ;
56+
57+ } else {
58+
59+ tiling . generateLevels ( levels , tiling . projection . tileCountX , tiling . projection . tileCountY , {
60+ tilePixelWidth : tileDimension ,
61+ tilePixelHeight : tileDimension ,
62+ } ) ;
63+
64+ }
4465
4566 this . url = url ;
4667
0 commit comments