Skip to content
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
4 changes: 4 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ program
"Url of a tileserver",
"http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
)
.option(
"-sub, --tileSubdomains <string>",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add one char option

"Subdomains of a tileserver"
)
.option(
"-m, --vectorserverUrl <string>",
"Url of a vector tile server (MVT style.json)"
Expand Down
6 changes: 6 additions & 0 deletions src/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ interface OsmStaticMapsOptions {
*/
tileserverUrl?: string;

/**
* tileSubdomains of a tileserver
* @defaultValue `undefined`
*/
tileSubdomains?: string[];

/**
* url of a vector tile server (MVT style.json)
* @defaultValue `undefined`
Expand Down
1 change: 1 addition & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = function(options) {
options.maxZoom = options.maxZoom || (options.vectorserverUrl ? 20 : 17);
options.attribution = options.attribution || 'osm-static-maps | © OpenStreetMap contributors';
options.tileserverUrl = options.tileserverUrl || 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
options.tileSubdomains = options.tileSubdomains || '';
options.vectorserverUrl = options.vectorserverUrl || '';
options.vectorserverToken = options.vectorserverToken || 'no-token';
options.imagemin = options.imagemin || false;
Expand Down
25 changes: 18 additions & 7 deletions src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,24 @@
}).addTo(map);
{{else}}
{{#if tileserverUrl}}
L.tileLayer(
'{{{tileserverUrl}}}',
{
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);
{{#if tileSubdomains }}
L.tileLayer(
'{{{tileserverUrl}}}',
{
subdomains: {{{tileSubdomains}}},
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);
{{else}}
L.tileLayer(
'{{{tileserverUrl}}}',
{
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);
{{/if}}
Comment on lines +133 to +150
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this if only in the subdomains part of the code

Suggested change
{{#if tileSubdomains }}
L.tileLayer(
'{{{tileserverUrl}}}',
{
subdomains: {{{tileSubdomains}}},
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);
{{else}}
L.tileLayer(
'{{{tileserverUrl}}}',
{
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);
{{/if}}
L.tileLayer(
'{{{tileserverUrl}}}',
{
{{#if tileSubdomains }}
subdomains: {{{tileSubdomains}}},
{{/if}}
maxZoom: maxZoom,
fadeAnimation: false
}
).addTo(map);

{{/if}}
{{/if}}

Expand Down