allow tileMargin option (#694)

* allow tileMargin option

tile mode does not support more than one tile in maplibre-native, so tileMargin needs static mode to work.

* add space
This commit is contained in:
Andrew Calcutt 2023-01-05 14:13:26 -05:00 committed by GitHub
parent b9df1d29d1
commit 138ac04676
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -615,6 +615,7 @@ export const serve_rendered = {
) {
return res.status(400).send('Invalid center');
}
if (
Math.min(width, height) <= 0 ||
Math.max(width, height) * scale > (options.maxSize || 2048) ||
@ -623,6 +624,7 @@ export const serve_rendered = {
) {
return res.status(400).send('Invalid size');
}
if (format === 'png' || format === 'webp') {
} else if (format === 'jpg' || format === 'jpeg') {
format = 'jpeg';
@ -630,8 +632,9 @@ export const serve_rendered = {
return res.status(400).send('Invalid format');
}
const tileMargin = Math.max(options.tileMargin || 0, 0);
let pool;
if (opt_mode === 'tile') {
if (opt_mode === 'tile' && tileMargin === 0) {
pool = item.map.renderers[scale];
} else {
pool = item.map.renderers_static[scale];
@ -646,12 +649,12 @@ export const serve_rendered = {
width: width,
height: height,
};
if (z === 0) {
params.width *= 2;
params.height *= 2;
}
const tileMargin = Math.max(options.tileMargin || 0, 0);
if (z > 2 && tileMargin > 0) {
params.width += tileMargin * 2;
params.height += tileMargin * 2;