$("<div>")
.attr("id", "export-warning")
.attr("class", "text-body-secondary")
- .text(I18n.t("javascripts.share.only_standard_layer"))
+ .text(I18n.t("javascripts.share.only_layers_exported_as_image"))
+ .append(
+ $("<ul>").append(
+ map.baseLayers
+ .filter(layer => layer.options.canDownloadImage)
+ .map(layer => $("<li>").text(layer.options.name))))
.appendTo($imageSection);
$form = $("<form>")
}
function update() {
- var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo";
+ const layer = map.getMapBaseLayer();
+ var canEmbed = Boolean(layer && layer.options.canEmbed);
var bounds = map.getBounds();
$("#link_marker")
$("#mapnik_image_width").text(mapWidth);
$("#mapnik_image_height").text(mapHeight);
- const layer = 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(layer) ? I18n.t(`javascripts.map.base.${layerKeys.get(layer)}`) : "");
- $("#map_format").val(layer);
+ $("#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);
$("#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() {