Manual lebab conversions
This commit is contained in:
parent
838bd73458
commit
d88eee9ca4
2 changed files with 17 additions and 37 deletions
|
@ -129,10 +129,7 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
onBlur: function () {
|
||||
var self = this
|
||||
setTimeout(() => {
|
||||
self.hide()
|
||||
}, 100)
|
||||
setTimeout(() => this.hide(), 100)
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
|
@ -217,12 +214,11 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
handleResults: function (data) {
|
||||
var self = this
|
||||
this.clear()
|
||||
this.container.style.display = 'block'
|
||||
this.resizeContainer()
|
||||
this.forEach(data, (item) => {
|
||||
self.RESULTS.push(self.createResult(item))
|
||||
this.RESULTS.push(this.createResult(item))
|
||||
})
|
||||
this.CURRENT = 0
|
||||
this.highlight()
|
||||
|
@ -230,9 +226,8 @@ L.U.AutoComplete = L.Class.extend({
|
|||
},
|
||||
|
||||
highlight: function () {
|
||||
var self = this
|
||||
this.forEach(this.RESULTS, (result, index) => {
|
||||
if (index === self.CURRENT) L.DomUtil.addClass(result.el, 'on')
|
||||
if (index === this.CURRENT) L.DomUtil.addClass(result.el, 'on')
|
||||
else L.DomUtil.removeClass(result.el, 'on')
|
||||
})
|
||||
},
|
||||
|
|
|
@ -343,9 +343,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
|
||||
reindex: function () {
|
||||
var features = []
|
||||
this.eachFeature((feature) => {
|
||||
features.push(feature)
|
||||
})
|
||||
this.eachFeature((feature) => features.push(feature))
|
||||
L.Util.sortFeatures(features, this.map.getOption('sortKey'))
|
||||
this._index = []
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
|
@ -366,18 +364,17 @@ L.U.DataLayer = L.Evented.extend({
|
|||
}
|
||||
if (!this.options.remoteData.dynamic && this.hasDataLoaded()) return
|
||||
if (!this.isVisible()) return
|
||||
var self = this,
|
||||
url = this.map.localizeUrl(this.options.remoteData.url)
|
||||
var url = this.map.localizeUrl(this.options.remoteData.url)
|
||||
if (this.options.remoteData.proxy)
|
||||
url = this.map.proxyUrl(url, this.options.remoteData.ttl)
|
||||
this.map.ajax({
|
||||
uri: url,
|
||||
verb: 'GET',
|
||||
callback: function (raw) {
|
||||
self.clear()
|
||||
self.rawToGeoJSON(raw, self.options.remoteData.format, (geojson) => {
|
||||
self.fromGeoJSON(geojson)
|
||||
})
|
||||
callback: (raw) => {
|
||||
this.clear()
|
||||
this.rawToGeoJSON(raw, this.options.remoteData.format, (geojson) =>
|
||||
this.fromGeoJSON(geojson)
|
||||
)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
@ -508,14 +505,10 @@ L.U.DataLayer = L.Evented.extend({
|
|||
},
|
||||
|
||||
addRawData: function (c, type) {
|
||||
var self = this
|
||||
this.rawToGeoJSON(c, type, (geojson) => {
|
||||
self.addData(geojson)
|
||||
})
|
||||
this.rawToGeoJSON(c, type, (geojson) => this.addData(geojson))
|
||||
},
|
||||
|
||||
rawToGeoJSON: function (c, type, callback) {
|
||||
var self = this
|
||||
var toDom = (x) => new DOMParser().parseFromString(x, 'text/xml')
|
||||
|
||||
// TODO add a duck typing guessType
|
||||
|
@ -537,7 +530,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
message: err[0].message,
|
||||
})
|
||||
}
|
||||
self.map.ui.alert({ content: message, level: 'error', duration: 10000 })
|
||||
this.map.ui.alert({ content: message, level: 'error', duration: 10000 })
|
||||
console.log(err)
|
||||
}
|
||||
if (result && result.features.length) {
|
||||
|
@ -564,7 +557,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
var gj = JSON.parse(c)
|
||||
callback(gj)
|
||||
} catch (err) {
|
||||
self.map.ui.alert({ content: 'Invalid JSON file: ' + err })
|
||||
this.map.ui.alert({ content: 'Invalid JSON file: ' + err })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -668,24 +661,18 @@ L.U.DataLayer = L.Evented.extend({
|
|||
},
|
||||
|
||||
importFromFile: function (f, type) {
|
||||
var reader = new FileReader(),
|
||||
self = this
|
||||
var reader = new FileReader()
|
||||
type = type || L.Util.detectFileType(f)
|
||||
reader.readAsText(f)
|
||||
reader.onload = (e) => {
|
||||
self.importRaw(e.target.result, type)
|
||||
}
|
||||
reader.onload = (e) => this.importRaw(e.target.result, type)
|
||||
},
|
||||
|
||||
importFromUrl: function (url, type) {
|
||||
url = this.map.localizeUrl(url)
|
||||
var self = this
|
||||
this.map.xhr._ajax({
|
||||
verb: 'GET',
|
||||
uri: url,
|
||||
callback: function (data) {
|
||||
self.importRaw(data, type)
|
||||
},
|
||||
callback: (data) => this.importRaw(data, type),
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -1032,9 +1019,7 @@ L.U.DataLayer = L.Evented.extend({
|
|||
|
||||
featuresToGeoJSON: function () {
|
||||
var features = []
|
||||
this.eachLayer((layer) => {
|
||||
features.push(layer.toGeoJSON())
|
||||
})
|
||||
this.eachLayer((layer) => features.push(layer.toGeoJSON()))
|
||||
return features
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue