Skip to content

Add maxZoom option #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The following options can be set:
|---|---|---|
|`date`|`Date`|Date for multi-temporal products|
|`transparent`|`Boolean`|Make no-data pixels of MODIS Multiband Imagery transparent|
|`maxZoom`|`Number`|Set a zoom level greater than the tileset provides to show auto-scaled tiles where needed (uses [maxNativeZoom](http://leafletjs.com/reference-1.0.3.html#tilelayer-maxnativezoom))|

**Note about `transparent` option.** GIBS Multiband Imagery layers use JPEG tiles without transparency (all no-data pixels are black). HTML Canvas and corresponding no-data layers are used to make no-data pixels transparent. It leads to additional requests to server and more computations in browser. So, use this option if you really need it!

Expand Down
9 changes: 7 additions & 2 deletions src/GIBSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
}

var dateStr = info.date ? date.getUTCFullYear() + '-' + s2(date.getUTCMonth() + 1) + '-' + s2(date.getUTCDate()) : "0";
var zMax = (info.maxZoom && z > info.zoom) ? info.zoom : z;

return L.Util.template(info.template, {
Time: dateStr,
TileMatrixSet: 'GoogleMapsCompatible_Level' + info.zoom,
TileMatrix: z,
TileMatrix: zMax,
TileRow: y,
TileCol: x
});
Expand All @@ -22,7 +23,11 @@
initialize: function(gibsID, options) {
this._layerInfo = L.GIBS_LAYERS[gibsID];
options = options || {};
options.maxZoom = this._layerInfo.zoom;
if(options.maxZoom) {
this._layerInfo.maxZoom = options.maxZoom;
options.maxNativeZoom = this._layerInfo.zoom;
}
options.maxZoom = options.maxZoom || this._layerInfo.zoom;
options.attribution = GIBS_ATTRIBUTION;
this._date = options.date || null;

Expand Down