Skip to content

Commit

Permalink
use url class throughout, remove redundant checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane98c committed Jun 17, 2023
1 parent e6bf9d7 commit 2050025
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/ol/source/BingMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,20 @@ class BingMaps extends TileImage {
tileCoord[2],
quadKeyTileCoord
);
let url = imageUrl;
const url = new URL(
imageUrl.replace('{quadkey}', quadKey(quadKeyTileCoord))
);
const params = url.searchParams;
if (hidpi) {
url += '&dpi=d1&device=mobile';
params.set('dpi', 'd1');
params.set('device', 'mobile');
}
url = url.replace('{quadkey}', quadKey(quadKeyTileCoord));
const uri = new URL(url);
const params = uri.searchParams;
if (placeholderTiles === true && params.has('n')) {
if (placeholderTiles === true) {
params.delete('n');
url = uri.toString();
} else if (placeholderTiles === false && !params.has('n')) {
params.append('n', 'z');
url = uri.toString();
} else if (placeholderTiles === false) {
params.set('n', 'z');
}
return url;
return url.toString();
}
);
})
Expand Down

0 comments on commit 2050025

Please sign in to comment.