//= require index/export
//= require index/key
//= require index/notes
+//= require index/map_ui
$(document).ready(function () {
var permalinks = $("#permalink").detach().html();
var marker;
var params = OSM.mapParams();
- var map = createMap("map");
+ var map = createMap("map", {layerControl: false});
+
+ OSM.mapUI().addTo(map);
L.control.scale().addTo(map);
});
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
- map.layersControl.addOverlay(dataLayer, I18n.t("browse.start_rjs.data_layer_name"));
+// map.layersControl.addOverlay(dataLayer, I18n.t("browse.start_rjs.data_layer_name"));
}
map.on('layeradd', function (e) {
--- /dev/null
+//= require templates/map/layers
+
+OSM.MapUI = L.Control.extend({
+ onAdd: function(map) {
+ this._initLayout(map);
+ return this._container;
+ },
+
+ _initLayout: function(map) {
+ var className = 'leaflet-control-map-ui',
+ container = this._container = L.DomUtil.create('div', className);
+
+ var link = this._layersLink = L.DomUtil.create('a', 'leaflet-map-ui-layers', container);
+ link.href = '#';
+ link.title = 'Layers';
+
+ this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
+
+ $(link).on('click', $.proxy(this.toggleLayers, this));
+ },
+
+ toggleLayers: function(e) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ if ($(this._uiPane).is(':visible')) {
+ $(this._uiPane).hide();
+ $(this._container).css({paddingRight: '0'})
+ } else {
+ $(this._uiPane)
+ .show()
+ .html(JST["templates/map/layers"]());
+ $(this._container).css({paddingRight: '200px'})
+ }
+ }
+});
+
+OSM.mapUI = function() {
+ return new OSM.MapUI();
+};
});
if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') {
- map.layersControl.addOverlay(noteLayer, I18n.t("browse.start_rjs.notes_layer_name"));
+// map.layersControl.addOverlay(noteLayer, I18n.t("browse.start_rjs.notes_layer_name"));
if (params.layers) setMapLayers(params.layers);
if (params.notes) map.addLayer(noteLayer);
--- /dev/null
+<h2>Layers</h2>
/*
*= require leaflet
*= require leaflet.locationfilter
+ *= require map-ui
*/
/* Override to serve images through the asset pipeline. */
--- /dev/null
+.leaflet-map-ui-layers {
+ box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
+ background: #f8f8f9;
+ -webkit-border-radius: 8px;
+ border-radius: 8px;
+ background-position: 50% 50%;
+ background-repeat: no-repeat;
+ display: block;
+ background-image: image-url("images/layers.png");
+ width: 36px;
+ height: 36px;
+}
+
+.leaflet-map-ui {
+ position: absolute;
+ display: none;
+ right: 0;
+ width: 200px;
+ height: 100%;
+ background: white;
+}