Skip to content

Commit

Permalink
Translate overlay type and fix width computation
Browse files Browse the repository at this point in the history
  • Loading branch information
bagage committed Mar 1, 2021
1 parent 9779756 commit 5331378
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
50 changes: 26 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,30 +222,32 @@ <h4 class="modal-title" data-i18n="layers.customize">Customize layers</h4>
placeholder="Custom layer URL. (ex: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png)"
/>

<button
type="button"
id="custom_layers_add_base"
class="btn btn-success"
data-i18n="layers.add-base"
>
Add base layer
</button>
<button
type="button"
id="custom_layers_add_overlay"
class="btn btn-success"
data-i18n="layers.add-overlay"
>
Add overlay
</button>
<button
type="button"
id="custom_layers_remove"
class="btn btn-danger"
data-i18n="layers.remove-selection"
>
Remove selection
</button>
<div>
<button
type="button"
id="custom_layers_add_base"
class="btn btn-success"
data-i18n="layers.add-base"
>
Add base layer
</button>
<button
type="button"
id="custom_layers_add_overlay"
class="btn btn-success"
data-i18n="layers.add-overlay"
>
Add overlay
</button>
<button
type="button"
id="custom_layers_remove"
class="btn btn-danger"
data-i18n="layers.remove-selection"
>
Remove selection
</button>
</div>
<table id="custom_layers_table"></table>
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions js/control/Layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ BR.Layers = L.Class.extend({
_loadTable: function () {
var layersData = [];
for (layer in this._customLayers) {
var isOverlay = this._customLayers[layer].isOverlay;
layersData.push([
layer,
this._customLayers[layer].layer._url,
this._customLayers[layer].isOverlay ? 'Overlay' : 'Layer',
isOverlay
? i18next.t('sidebar.layers.table.type_overlay')
: i18next.t('sidebar.layers.table.type_layer'),
]);
}
if (this._layersTable != null) {
this._layersTable.destroy();
}

this._layersTable = $('#custom_layers_table').DataTable({
data: layersData,
info: false,
searching: false,
bAutoWidth: false,
paging: false,
language: {
emptyTable: i18next.t('sidebar.layers.table.empty'),
Expand All @@ -37,6 +40,7 @@ BR.Layers = L.Class.extend({
{ title: i18next.t('sidebar.layers.table.type') },
],
});
this._layersTable.columns.adjust();
},

init: function (map, layersControl, baseLayers, overlays) {
Expand Down
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@
"URL": "URL",
"empty": "No custom layer configured yet.",
"name": "Name",
"type": "Type"
"type": "Type",
"type_layer": "Layer",
"type_overlay": "Overlay"
},
"title": "Layers",
"tooltip": "Select layers"
Expand Down

0 comments on commit 5331378

Please sign in to comment.