X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/33aa0a6e454fb2d43b8ccc07395abf0864d47b66..f1a4669c957d29c012466768581c4a801e5029be:/app/assets/javascripts/leaflet.layers.js?ds=inline diff --git a/app/assets/javascripts/leaflet.layers.js b/app/assets/javascripts/leaflet.layers.js index 6c83f0c2f..09cf1cf60 100644 --- a/app/assets/javascripts/leaflet.layers.js +++ b/app/assets/javascripts/leaflet.layers.js @@ -1,25 +1,132 @@ -//= require templates/map/layers - L.OSM.Layers = L.Control.extend({ onAdd: function (map) { - this._initLayout(map); - return this._container; + this._map = map; + this._initLayout(); + return this.$container[0]; }, - _initLayout: function (map) { - var className = 'leaflet-control-map-ui', - container = this._container = L.DomUtil.create('div', className); + _initLayout: function () { + var map = this._map, + layers = this.options.layers; + + this.$container = $('
') + .attr('class', 'control-layers'); + + var link = $('') + .attr('class', 'control-button') + .attr('href', '#') + .attr('title', 'Layers') + .html('') + .appendTo(this.$container); + + if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { + this.$ui = $('
') + .attr('class', 'layers-ui') + .appendTo(this.options.uiPane); + + $('

') + .text(I18n.t('javascripts.map.layers.header')) + .appendTo(this.$ui); + + var overlaySection = $('
') + .addClass('overlay-layers') + .appendTo(this.$ui); + + $('

') + .text(I18n.t('javascripts.map.layers.overlays')) + .appendTo(overlaySection); - var link = this._layersLink = L.DomUtil.create('a', 'leaflet-map-ui-layers', container); - link.href = '#'; - link.title = 'Layers'; + var list = $('

    ') + .appendTo(overlaySection); - this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container); + function addOverlay(layer, name) { + var item = $('
  • ') + .appendTo(list); + + var label = $('