Add 'canDownloadImage' layer option

This commit is contained in:
Anton Khorev 2024-12-18 19:41:25 +03:00
parent 1c2a7b0a07
commit 6c1704b245
2 changed files with 10 additions and 21 deletions

View file

@ -338,7 +338,7 @@ L.OSM.share = function (options) {
function update() {
const layer = map.getMapBaseLayer();
var canEmbed = layer && layer.options.canEmbed;
var canEmbed = Boolean(layer && layer.options.canEmbed);
var bounds = map.getBounds();
$("#link_marker")
@ -411,15 +411,10 @@ L.OSM.share = function (options) {
$("#mapnik_image_width").text(mapWidth);
$("#mapnik_image_height").text(mapHeight);
const layerId = map.getMapBaseLayerId();
const layerKeys = new Map([
["mapnik", "standard"],
["cyclemap", "cycle_map"],
["transportmap", "transport_map"]
]);
const canDownloadImage = Boolean(layer && layer.options.canDownloadImage);
$("#mapnik_image_layer").text(layerKeys.has(layerId) ? I18n.t(`javascripts.map.base.${layerKeys.get(layerId)}`) : "");
$("#map_format").val(layerId);
$("#mapnik_image_layer").text(canDownloadImage ? layer.options.name : "");
$("#map_format").val(canDownloadImage ? layer.options.layerId : "");
$("#map_zoom").val(map.getZoom());
$("#mapnik_lon").val(map.getCenter().lng);
@ -427,18 +422,9 @@ L.OSM.share = function (options) {
$("#map_width").val(mapWidth);
$("#map_height").val(mapHeight);
if (["cyclemap", "transportmap"].includes(map.getMapBaseLayerId())) {
$("#export-image").show();
$("#mapnik_scale_row").hide();
$("#export-warning").hide();
} else if (map.getMapBaseLayerId() === "mapnik") {
$("#export-image").show();
$("#mapnik_scale_row").show();
$("#export-warning").hide();
} else {
$("#export-image").hide();
$("#export-warning").show();
}
$("#export-image").toggle(canDownloadImage);
$("#export-warning").toggle(!canDownloadImage);
$("#mapnik_scale_row").toggle(canDownloadImage && layer.options.layerId === "mapnik");
}
function select() {

View file

@ -3,6 +3,7 @@
layerId: "mapnik"
nameId: "standard"
canEmbed: true
canDownloadImage: true
credit:
id: "make_a_donation"
href: "https://supporting.openstreetmap.org"
@ -29,6 +30,7 @@
nameId: "cycle_map"
apiKeyId: "THUNDERFOREST_KEY"
canEmbed: true
canDownloadImage: true
credit:
id: "thunderforest_credit"
children:
@ -42,6 +44,7 @@
nameId: "transport_map"
apiKeyId: "THUNDERFOREST_KEY"
canEmbed: true
canDownloadImage: true
credit:
id: "thunderforest_credit"
children: