]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.note.js
Start refactoring notes layer
[rails.git] / app / assets / javascripts / leaflet.note.js
diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js
new file mode 100644 (file)
index 0000000..14a3364
--- /dev/null
@@ -0,0 +1,27 @@
+L.Control.Note = L.Control.extend({
+    options: {
+        position: 'topright',
+        title: 'Notes',
+    },
+
+    onAdd: function (map) {
+        var className = 'leaflet-control-locate',
+            classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control',
+            container = L.DomUtil.create('div', classNames);
+
+        var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
+        link.href = '#';
+        link.title = this.options.title;
+
+        L.DomEvent
+            .on(link, 'click', L.DomEvent.stopPropagation)
+            .on(link, 'click', L.DomEvent.preventDefault)
+            .on(link, 'dblclick', L.DomEvent.stopPropagation);
+
+        return container;
+    }
+});
+
+L.control.note = function(options) {
+    return new L.Control.Note(options);
+};