X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/22d6633114d02af0e543afbb23cc05e33d1a1c9d..ef73cc1f574124b10cda75188aa542d9f4d802bb:/app/assets/javascripts/leaflet.note.js diff --git a/app/assets/javascripts/leaflet.note.js b/app/assets/javascripts/leaflet.note.js index 14a33640a..24f18f7ab 100644 --- a/app/assets/javascripts/leaflet.note.js +++ b/app/assets/javascripts/leaflet.note.js @@ -5,20 +5,32 @@ L.Control.Note = L.Control.extend({ }, onAdd: function (map) { - var className = 'leaflet-control-locate', - classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control', - container = L.DomUtil.create('div', classNames); + var className = 'control-note', + container = L.DomUtil.create('div', className); - var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container); + var link = L.DomUtil.create('a', 'control-button', container); + link.innerHTML = ""; link.href = '#'; link.title = this.options.title; L.DomEvent .on(link, 'click', L.DomEvent.stopPropagation) .on(link, 'click', L.DomEvent.preventDefault) + .on(link, 'click', this._toggle, this) .on(link, 'dblclick', L.DomEvent.stopPropagation); + this.map = map; + return container; + }, + + // TODO: this relies on notesLayer on the map + _toggle: function() { + if (this.map.hasLayer(this.map.noteLayer)) { + this.map.removeLayer(this.map.noteLayer); + } else { + this.map.addLayer(this.map.noteLayer); + } } });