-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 6fb47bc Merge: 3da01fc 818fee4 Author: nreese <[email protected]> Date: Tue Dec 13 15:30:20 2016 -0700 display geo_distance filters in Applied Filters layer commit 3da01fc Author: nreese <[email protected]> Date: Tue Dec 13 14:01:04 2016 -0700 remove toolbar tool when poi layers are cleared commit db0a1fd Author: nreese <[email protected]> Date: Tue Dec 13 13:23:29 2016 -0700 add control to L.draw.toolbar to create POI filters commit e3062b2 Author: nreese <[email protected]> Date: Fri Dec 9 14:34:41 2016 -0700 make popup marker with button to trigger filter creation commit 8b796ac Author: nreese <[email protected]> Date: Wed Dec 7 16:56:47 2016 -0700 experement with geo_distance filter commit 38888f5 Author: nreese <[email protected]> Date: Fri Dec 9 14:34:41 2016 -0700 make popup marker with button to trigger filter creation commit 527fa1d Author: nreese <[email protected]> Date: Wed Dec 7 16:56:47 2016 -0700 experement with geo_distance filter commit 818fee4 Author: nreese <[email protected]> Date: Tue Dec 13 14:01:04 2016 -0700 remove toolbar tool when poi layers are cleared commit b6d442e Author: nreese <[email protected]> Date: Tue Dec 13 13:23:29 2016 -0700 add control to L.draw.toolbar to create POI filters commit e784c2d Merge: b2d0cc9 380a4b7 Author: nreese <[email protected]> Date: Mon Dec 12 16:21:21 2016 -0700 rebase conflicts commit b2d0cc9 Author: nreese <[email protected]> Date: Fri Dec 9 14:34:41 2016 -0700 make popup marker with button to trigger filter creation commit 6a9412a Author: nreese <[email protected]> Date: Wed Dec 7 16:56:47 2016 -0700 experement with geo_distance filter commit 380a4b7 Author: nreese <[email protected]> Date: Fri Dec 9 14:34:41 2016 -0700 make popup marker with button to trigger filter creation commit 31b6124 Author: nreese <[email protected]> Date: Wed Dec 7 16:56:47 2016 -0700 experement with geo_distance filter
- Loading branch information
Showing
6 changed files
with
272 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
//Adds additional tools to the standard leafelt.draw toolbar | ||
define(function (require) { | ||
function LDrawToolbench(map, drawControl) { | ||
this._map = map; | ||
|
||
const container = drawControl.getContainer().firstChild; | ||
this._actionsContainer = container.getElementsByClassName('leaflet-draw-actions')[0]; | ||
this._toolbarContainer = container.getElementsByClassName('leaflet-draw-toolbar')[0]; | ||
} | ||
|
||
LDrawToolbench.prototype.addTool = function () { | ||
const self = this; | ||
_createButton({ | ||
title: "Create geo_distance filter around POIs", | ||
className: 'leaflet-draw-draw-circle leaflet-toolbench-tool', | ||
container: this._toolbarContainer, | ||
callback: function() { | ||
self.displayActions(); | ||
}, | ||
context: {} | ||
}); | ||
} | ||
|
||
LDrawToolbench.prototype.removeTools = function () { | ||
const tools = this._toolbarContainer.getElementsByClassName('leaflet-toolbench-tool'); | ||
for (var i = 0; i < tools.length; i++) { | ||
const elem = tools[i]; | ||
elem.parentNode.removeChild(elem); | ||
} | ||
} | ||
|
||
LDrawToolbench.prototype.clearActions = function () { | ||
while (this._actionsContainer.firstChild) { | ||
this._actionsContainer.removeChild(this._actionsContainer.firstChild); | ||
} | ||
} | ||
|
||
LDrawToolbench.prototype.displayActions = function () { | ||
const self = this; | ||
|
||
self.clearActions(); | ||
|
||
let radius = 10; | ||
|
||
_createInput({ | ||
container: L.DomUtil.create('li', '', this._actionsContainer), | ||
inputType: 'number', | ||
name: 'radius', | ||
placeholder: 'radius (km)', | ||
callback: function(event) { | ||
radius = getValue(event); | ||
if (radius <= 0) radius = 10; | ||
} | ||
}); | ||
_createButton({ | ||
title: "Create geo_distance filters POI layer markers.", | ||
text: "Create", | ||
container: L.DomUtil.create('li', '', this._actionsContainer), | ||
callback: function() { | ||
self._map.fire('toolbench:poiFilter', {radius: radius}); | ||
self._actionsContainer.style.display = 'none'; | ||
self.clearActions(); | ||
} | ||
}); | ||
_createButton({ | ||
title: "Click to cancel.", | ||
text: "Cancel", | ||
container: L.DomUtil.create('li', '', this._actionsContainer), | ||
callback: function() { | ||
self._actionsContainer.style.display = 'none'; | ||
self.clearActions(); | ||
} | ||
}); | ||
|
||
//Make actions visible and located next to toolbar button | ||
const numTools = this._toolbarContainer.children.length; | ||
const actionBarLocation = 25 * (numTools - 1); | ||
this._actionsContainer.style.top = actionBarLocation + 'px'; | ||
this._actionsContainer.style.display = 'block'; | ||
} | ||
|
||
function _createButton (options) { | ||
var link = L.DomUtil.create('a', options.className || '', options.container); | ||
link.href = '#'; | ||
if (options.text) { | ||
link.innerHTML = options.text; | ||
} | ||
if (options.title) { | ||
link.title = options.title; | ||
} | ||
|
||
L.DomEvent | ||
.on(link, 'click', L.DomEvent.stopPropagation) | ||
.on(link, 'mousedown', L.DomEvent.stopPropagation) | ||
.on(link, 'dblclick', L.DomEvent.stopPropagation) | ||
.on(link, 'click', L.DomEvent.preventDefault) | ||
.on(link, 'click', options.callback, options.context); | ||
|
||
return link; | ||
} | ||
|
||
function _createInput (options) { | ||
var input = L.DomUtil.create('input', options.className || '', options.container); | ||
input.type = options.inputType; | ||
if (options.placeholder) { | ||
input.placeholder = options.placeholder; | ||
input.title = options.placeholder; | ||
} | ||
if (options.value) { | ||
input.value = options.value; | ||
} | ||
L.DomEvent | ||
.on(input, 'mousedown', L.DomEvent.stopPropagation) | ||
.on(input, 'dblclick', L.DomEvent.stopPropagation) | ||
if (options.callback) { | ||
L.DomEvent | ||
.on(input, 'change', options.callback); | ||
} | ||
return input; | ||
} | ||
|
||
function getValue (event) { | ||
const el = event.target || event.srcElement; | ||
return el.value; | ||
} | ||
|
||
return LDrawToolbench; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.