]> git.openstreetmap.org Git - rails.git/commitdiff
Use a radio button for base layers
authorJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 8 Jul 2013 21:27:13 +0000 (14:27 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Thu, 18 Jul 2013 17:45:16 +0000 (10:45 -0700)
app/assets/javascripts/leaflet.layers.js

index 8653a0921a3ade64badecb96ff244f723e3cd48c..2f06ab9c577aa7105f3ff51408c183476d51f5c0 100644 (file)
@@ -81,9 +81,15 @@ L.OSM.layers = function(options) {
       });
 
       var label = $('<label>')
-        .text(layer.options.name)
         .appendTo(item);
 
+      var input = $('<input>')
+        .attr('type', 'radio')
+        .prop('checked', map.hasLayer(layer))
+        .appendTo(label);
+
+      label.append(layer.options.name);
+
       item.on('click', function() {
         layers.forEach(function(other) {
           if (other === layer) {
@@ -97,6 +103,7 @@ L.OSM.layers = function(options) {
 
       map.on('layeradd layerremove', function() {
         item.toggleClass('active', map.hasLayer(layer));
+        input.prop('checked', map.hasLayer(layer));
       });
     });