map: show buttons along content buttons
This commit is contained in:
parent
cc3d591bd0
commit
144dba319e
4 changed files with 45 additions and 34 deletions
23
lib/map.js
23
lib/map.js
|
|
@ -18,6 +18,7 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
|
||||
onAdd: function () {
|
||||
var button = L.DomUtil.create("button", "add-layer")
|
||||
button.textContent = ""
|
||||
|
||||
L.DomEvent.disableClickPropagation(button)
|
||||
L.DomEvent.addListener(button, "click", this.f, this)
|
||||
|
|
@ -43,6 +44,7 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
|
||||
onAdd: function () {
|
||||
var button = L.DomUtil.create("button", "locate-user")
|
||||
button.textContent = ""
|
||||
|
||||
L.DomEvent.disableClickPropagation(button)
|
||||
L.DomEvent.addListener(button, "click", this.onClick, this)
|
||||
|
|
@ -118,7 +120,7 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
var iconAlert = { color: "#D43E2A", fillColor: "#D43E2A", radius: 6, fillOpacity: 0.8, opacity: 0.8, weight: 2, className: "stroke-first node-alert" }
|
||||
var iconNew = { color: "#1566A9", fillColor: "#93E929", radius: 6, fillOpacity: 1.0, opacity: 0.5, weight: 2 }
|
||||
|
||||
return function (config, linkScale, sidebar, router) {
|
||||
return function (config, linkScale, sidebar, router, buttons) {
|
||||
var self = this
|
||||
var barycenter
|
||||
var groupOnline, groupOffline, groupNew, groupLost, groupLines
|
||||
|
|
@ -135,6 +137,20 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
disableTracking()
|
||||
})
|
||||
|
||||
var mybuttons = []
|
||||
|
||||
function addButton(button) {
|
||||
var el = button.onAdd()
|
||||
mybuttons.push(el)
|
||||
buttons.appendChild(el)
|
||||
}
|
||||
|
||||
function clearButtons() {
|
||||
mybuttons.forEach( function (d) {
|
||||
buttons.removeChild(d)
|
||||
})
|
||||
}
|
||||
|
||||
function saveView() {
|
||||
savedView = {center: map.getCenter(),
|
||||
zoom: map.getZoom()}
|
||||
|
|
@ -207,9 +223,9 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
map.on("locationerror", locationError)
|
||||
map.on("dragend", saveView)
|
||||
|
||||
map.addControl(locateUserButton)
|
||||
addButton(locateUserButton)
|
||||
|
||||
map.addControl(new AddLayerButton(function () {
|
||||
addButton(new AddLayerButton(function () {
|
||||
/*eslint no-alert:0*/
|
||||
var layerName = prompt("Leaflet Provider:")
|
||||
addLayer(layerName)
|
||||
|
|
@ -400,6 +416,7 @@ define(["map/clientlayer", "map/labelslayer",
|
|||
}
|
||||
|
||||
self.destroy = function () {
|
||||
clearButtons()
|
||||
map.remove()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue