Browse Source

CategoryOverpass: Specify filters on results (basic commit)

master
parent
commit
034023fe1f
  1. 1
      lang/de.json
  2. 1
      lang/en.json
  3. 51
      src/CategoryOverpass.js

1
lang/de.json

@ -16,6 +16,7 @@
"export:OSMJSON": "",
"export:OSMXML": null,
"facilities": "Einrichtungen",
"filter_results": "Ergebnisse einschränken",
"header:attributes": "Attribute",
"header:export": "Export",
"header:osm_meta": "OSM Meta",

1
lang/en.json

@ -16,6 +16,7 @@
"export:OSMJSON": "Download as OSM JSON",
"export:OSMXML": "Download as OSM XML",
"facilities": "Facilities",
"filter_results": "Filter results",
"header:attributes": "Attributes",
"header:export": "Export",
"header:osm_meta": "OSM Meta",

51
src/CategoryOverpass.js

@ -108,7 +108,48 @@ function CategoryOverpass (options, data) {
this.layer.on('remove', (ob, data) => this.emit('remove', ob, data))
this.layer.on('zoomChange', (ob, data) => this.emit('remove', ob, data))
p = document.createElement('div')
if (this.data.filter) {
this.domFilter = document.createElement('form')
this.formFilter = new form(this.id, this.data.filter,
{
'type': 'form_chooser',
'button:add_element': '-- ' + lang('filter_results') + ' --',
'order': false
}
)
this.formFilter.show(this.domFilter)
this.formFilter.onchange = function () {
var data = this.formFilter.get_data()
this.additionalFilter = []
for (var k in data) {
if (data[k] === null) {
continue
}
var d = this.data.filter[k]
var v = {
key: k,
value: data[k],
op: '='
}
if ('op' in d) {
v.op = d.op
}
this.additionalFilter.push(v)
}
this.layer.options.queryOptions.filter = this.additionalFilter
this.layer.check_update_map()
}.bind(this)
this.dom.insertBefore(this.domFilter, this.domContent)
}
var p = document.createElement('div')
p.className = 'loadingIndicator'
p.innerHTML = '<i class="fa fa-spinner fa-pulse fa-fw"></i><span class="sr-only">' + lang('loading') + '</span>'
this.dom.appendChild(p)
@ -193,6 +234,14 @@ CategoryOverpass.prototype.load = function (callback) {
}.bind(this))
}
CategoryOverpass.prototype.setParentDom = function (parentDom) {
CategoryBase.prototype.setParentDom.call(this, parentDom)
if (this.formFilter) {
this.formFilter.resize()
}
}
CategoryOverpass.prototype.setMap = function (map) {
CategoryBase.prototype.setMap.call(this, map)

Loading…
Cancel
Save