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

View file

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