Skip to content

Commit

Permalink
Add 'canEmbed' layer option
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Dec 9, 2024
1 parent 83f436c commit 959a28a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/assets/javascripts/leaflet.share.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ L.OSM.share = function (options) {
}

function update() {
var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo";
const layer = map.getMapBaseLayer();
var canEmbed = layer && layer.options.canEmbed;
var bounds = map.getBounds();

$("#link_marker")
Expand Down Expand Up @@ -410,15 +411,15 @@ L.OSM.share = function (options) {
$("#mapnik_image_width").text(mapWidth);
$("#mapnik_image_height").text(mapHeight);

const layer = map.getMapBaseLayerId();
const layerId = map.getMapBaseLayerId();
const layerKeys = new Map([
["mapnik", "standard"],
["cyclemap", "cycle_map"],
["transportmap", "transport_map"]
]);

$("#mapnik_image_layer").text(layerKeys.has(layer) ? I18n.t(`javascripts.map.base.${layerKeys.get(layer)}`) : "");
$("#map_format").val(layer);
$("#mapnik_image_layer").text(layerKeys.has(layerId) ? I18n.t(`javascripts.map.base.${layerKeys.get(layerId)}`) : "");
$("#map_format").val(layerId);

$("#map_zoom").val(map.getZoom());
$("#mapnik_lon").val(map.getCenter().lng);
Expand Down
5 changes: 5 additions & 0 deletions config/layers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
code: "M"
keyId: "mapnik"
nameId: "standard"
canEmbed: true
credit:
id: "make_a_donation"
href: "https://supporting.openstreetmap.org"
Expand All @@ -11,6 +12,7 @@
code: "Y"
keyId: "cyclosm"
nameId: "cyclosm"
canEmbed: true
credit:
id: "cyclosm_credit"
children:
Expand All @@ -26,6 +28,7 @@
keyId: "cyclemap"
nameId: "cycle_map"
apiKeyId: "THUNDERFOREST_KEY"
canEmbed: true
credit:
id: "thunderforest_credit"
children:
Expand All @@ -38,6 +41,7 @@
keyId: "transportmap"
nameId: "transport_map"
apiKeyId: "THUNDERFOREST_KEY"
canEmbed: true
credit:
id: "thunderforest_credit"
children:
Expand All @@ -61,6 +65,7 @@
code: "H"
keyId: "hot"
nameId: "hot"
canEmbed: true
credit:
id: "hotosm_credit"
children:
Expand Down

0 comments on commit 959a28a

Please sign in to comment.