}
function update() {
- var layer = map.getMapBaseLayerId(),
+ var layerId = map.getMapBaseLayerId(),
zoom = map.getZoom();
$(".mapkey-table-entry").each(function () {
var data = $(this).data();
$(this).toggle(
- layer === data.layer &&
+ layerId === data.layer &&
(!data.zoomMin || zoom >= data.zoomMin) &&
(!data.zoomMax || zoom <= data.zoomMax)
);
},
getMapBaseLayerId: function () {
- var baseLayerId;
- this.eachLayer(function (layer) {
- if (layer.options && layer.options.layerId) baseLayerId = layer.options.layerId;
- });
- return baseLayerId;
+ const layer = this.getMapBaseLayer();
+ if (layer) return layer.options.layerId;
+ },
+
+ getMapBaseLayer: function () {
+ for (const layer of this.baseLayers) {
+ if (this.hasLayer(layer)) return layer;
+ }
},
getUrl: function (marker) {
}
function update() {
- var canEmbed = map.getMapBaseLayerId() !== "tracestracktopo";
+ const layer = map.getMapBaseLayer();
+ var canEmbed = 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 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);
code: "M"
layerId: "mapnik"
nameId: "standard"
+ canEmbed: true
credit:
id: "make_a_donation"
href: "https://supporting.openstreetmap.org"
code: "Y"
layerId: "cyclosm"
nameId: "cyclosm"
+ canEmbed: true
credit:
id: "cyclosm_credit"
children:
layerId: "cyclemap"
nameId: "cycle_map"
apiKeyId: "THUNDERFOREST_KEY"
+ canEmbed: true
credit:
id: "thunderforest_credit"
children:
layerId: "transportmap"
nameId: "transport_map"
apiKeyId: "THUNDERFOREST_KEY"
+ canEmbed: true
credit:
id: "thunderforest_credit"
children:
code: "H"
layerId: "hot"
nameId: "hot"
+ canEmbed: true
credit:
id: "hotosm_credit"
children: