umap-project 3.4.2__py3-none-any.whl → 3.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- umap/__init__.py +1 -1
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +71 -57
- umap/locale/de/LC_MESSAGES/django.mo +0 -0
- umap/locale/de/LC_MESSAGES/django.po +20 -16
- umap/locale/en/LC_MESSAGES/django.po +14 -14
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +20 -16
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +32 -27
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +20 -16
- umap/management/commands/clean_tilelayer.py +0 -1
- umap/management/commands/search_maps.py +95 -0
- umap/settings/__init__.py +9 -1
- umap/settings/base.py +7 -6
- umap/static/umap/css/icon.css +8 -0
- umap/static/umap/img/16-white.svg +5 -2
- umap/static/umap/img/16.svg +1 -1
- umap/static/umap/img/source/16-white.svg +7 -4
- umap/static/umap/img/source/16.svg +1 -1
- umap/static/umap/js/modules/autocomplete.js +1 -9
- umap/static/umap/js/modules/browser.js +27 -10
- umap/static/umap/js/modules/data/features.js +3 -2
- umap/static/umap/js/modules/data/fields.js +12 -2
- umap/static/umap/js/modules/data/layer.js +13 -9
- umap/static/umap/js/modules/domutils.js +4 -0
- umap/static/umap/js/modules/filters.js +11 -10
- umap/static/umap/js/modules/form/builder.js +17 -16
- umap/static/umap/js/modules/form/fields.js +16 -16
- umap/static/umap/js/modules/permissions.js +10 -2
- umap/static/umap/js/modules/rendering/controls.js +202 -9
- umap/static/umap/js/modules/rendering/layers/classified.js +1 -1
- umap/static/umap/js/modules/rendering/map.js +45 -35
- umap/static/umap/js/modules/rendering/template.js +12 -6
- umap/static/umap/js/modules/rules.js +1 -1
- umap/static/umap/js/modules/ui/bar.js +2 -1
- umap/static/umap/js/modules/ui/hash.js +36 -0
- umap/static/umap/js/modules/ui/loader.js +26 -0
- umap/static/umap/js/modules/ui/panel.js +7 -0
- umap/static/umap/js/modules/umap.js +6 -0
- umap/static/umap/js/modules/utils.js +5 -4
- umap/static/umap/js/umap.controls.js +0 -182
- umap/static/umap/locale/am_ET.js +2 -5
- umap/static/umap/locale/am_ET.json +2 -5
- umap/static/umap/locale/ar.js +2 -5
- umap/static/umap/locale/ar.json +2 -5
- umap/static/umap/locale/ast.js +2 -5
- umap/static/umap/locale/ast.json +2 -5
- umap/static/umap/locale/bg.js +2 -5
- umap/static/umap/locale/bg.json +2 -5
- umap/static/umap/locale/br.js +40 -43
- umap/static/umap/locale/br.json +40 -43
- umap/static/umap/locale/ca.js +2 -5
- umap/static/umap/locale/ca.json +2 -5
- umap/static/umap/locale/cs_CZ.js +0 -3
- umap/static/umap/locale/cs_CZ.json +0 -3
- umap/static/umap/locale/da.js +1 -4
- umap/static/umap/locale/da.json +1 -4
- umap/static/umap/locale/de.js +27 -30
- umap/static/umap/locale/de.json +27 -30
- umap/static/umap/locale/el.js +0 -3
- umap/static/umap/locale/el.json +0 -3
- umap/static/umap/locale/en.js +0 -3
- umap/static/umap/locale/en.json +0 -3
- umap/static/umap/locale/en_US.json +2 -5
- umap/static/umap/locale/es.js +0 -3
- umap/static/umap/locale/es.json +0 -3
- umap/static/umap/locale/et.js +0 -3
- umap/static/umap/locale/et.json +0 -3
- umap/static/umap/locale/eu.js +0 -3
- umap/static/umap/locale/eu.json +0 -3
- umap/static/umap/locale/fa_IR.js +0 -3
- umap/static/umap/locale/fa_IR.json +0 -3
- umap/static/umap/locale/fi.js +2 -5
- umap/static/umap/locale/fi.json +2 -5
- umap/static/umap/locale/fr.js +3 -6
- umap/static/umap/locale/fr.json +3 -6
- umap/static/umap/locale/gl.js +0 -3
- umap/static/umap/locale/gl.json +0 -3
- umap/static/umap/locale/he.js +2 -5
- umap/static/umap/locale/he.json +2 -5
- umap/static/umap/locale/hr.js +2 -5
- umap/static/umap/locale/hr.json +2 -5
- umap/static/umap/locale/hu.js +7 -10
- umap/static/umap/locale/hu.json +7 -10
- umap/static/umap/locale/id.js +2 -5
- umap/static/umap/locale/id.json +2 -5
- umap/static/umap/locale/is.js +0 -3
- umap/static/umap/locale/is.json +0 -3
- umap/static/umap/locale/it.js +0 -3
- umap/static/umap/locale/it.json +0 -3
- umap/static/umap/locale/ja.js +2 -5
- umap/static/umap/locale/ja.json +2 -5
- umap/static/umap/locale/ko.js +2 -5
- umap/static/umap/locale/ko.json +2 -5
- umap/static/umap/locale/lt.js +2 -5
- umap/static/umap/locale/lt.json +2 -5
- umap/static/umap/locale/ms.js +0 -3
- umap/static/umap/locale/ms.json +0 -3
- umap/static/umap/locale/nl.js +0 -3
- umap/static/umap/locale/nl.json +0 -3
- umap/static/umap/locale/no.js +2 -5
- umap/static/umap/locale/no.json +2 -5
- umap/static/umap/locale/pl.js +2 -5
- umap/static/umap/locale/pl.json +2 -5
- umap/static/umap/locale/pl_PL.json +2 -5
- umap/static/umap/locale/pt.js +0 -3
- umap/static/umap/locale/pt.json +0 -3
- umap/static/umap/locale/pt_BR.js +2 -5
- umap/static/umap/locale/pt_BR.json +2 -5
- umap/static/umap/locale/pt_PT.js +2 -5
- umap/static/umap/locale/pt_PT.json +2 -5
- umap/static/umap/locale/ro.js +2 -5
- umap/static/umap/locale/ro.json +2 -5
- umap/static/umap/locale/ru.js +2 -5
- umap/static/umap/locale/ru.json +2 -5
- umap/static/umap/locale/sk_SK.js +2 -5
- umap/static/umap/locale/sk_SK.json +2 -5
- umap/static/umap/locale/sl.js +2 -5
- umap/static/umap/locale/sl.json +2 -5
- umap/static/umap/locale/sr.js +2 -5
- umap/static/umap/locale/sr.json +2 -5
- umap/static/umap/locale/sv.js +2 -5
- umap/static/umap/locale/sv.json +2 -5
- umap/static/umap/locale/th_TH.js +2 -5
- umap/static/umap/locale/th_TH.json +2 -5
- umap/static/umap/locale/tr.js +2 -5
- umap/static/umap/locale/tr.json +2 -5
- umap/static/umap/locale/uk_UA.js +2 -5
- umap/static/umap/locale/uk_UA.json +2 -5
- umap/static/umap/locale/vi.js +2 -5
- umap/static/umap/locale/vi.json +2 -5
- umap/static/umap/locale/vi_VN.json +2 -5
- umap/static/umap/locale/zh.js +2 -5
- umap/static/umap/locale/zh.json +2 -5
- umap/static/umap/locale/zh_CN.json +2 -5
- umap/static/umap/locale/zh_TW.Big5.json +2 -5
- umap/static/umap/locale/zh_TW.js +1 -4
- umap/static/umap/locale/zh_TW.json +1 -4
- umap/static/umap/map.css +1 -17
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.esm.js +942 -0
- umap/static/umap/vendors/photon/leaflet.photon.esm.js +472 -0
- umap/sync/app.py +4 -1
- umap/templates/umap/css.html +0 -2
- umap/templates/umap/js.html +0 -5
- umap/templates/umap/team_form.html +2 -1
- umap/tests/fixtures/test_upload_data_with_enum.umap +151 -0
- umap/tests/integration/test_edit_map.py +2 -0
- umap/tests/integration/test_filters.py +24 -0
- umap/tests/integration/test_import.py +40 -23
- umap/tests/integration/test_map.py +1 -1
- umap/tests/integration/test_optimistic_merge.py +7 -1
- umap/tests/integration/test_remote_data.py +1 -1
- umap/tests/test_search_maps_command.py +44 -0
- umap/utils.py +9 -3
- umap/views.py +17 -4
- {umap_project-3.4.2.dist-info → umap_project-3.6.1.dist-info}/METADATA +24 -18
- {umap_project-3.4.2.dist-info → umap_project-3.6.1.dist-info}/RECORD +162 -163
- {umap_project-3.4.2.dist-info → umap_project-3.6.1.dist-info}/WHEEL +1 -1
- umap/static/umap/vendors/hash/leaflet-hash.js +0 -162
- umap/static/umap/vendors/loading/Control.Loading.css +0 -26
- umap/static/umap/vendors/loading/Control.Loading.js +0 -351
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.css +0 -1
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.css.map +0 -1
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js +0 -4
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map +0 -1
- umap/static/umap/vendors/photon/leaflet.photon.js +0 -487
- {umap_project-3.4.2.dist-info → umap_project-3.6.1.dist-info}/entry_points.txt +0 -0
- {umap_project-3.4.2.dist-info → umap_project-3.6.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
L.PhotonBase = L.Class.extend({
|
|
2
|
-
|
|
3
|
-
forEach: function (els, callback) {
|
|
4
|
-
Array.prototype.forEach.call(els, callback);
|
|
5
|
-
},
|
|
6
|
-
|
|
7
|
-
ajax: function (callback, thisobj) {
|
|
8
|
-
if (typeof this.xhr === 'object') {
|
|
9
|
-
this.xhr.abort();
|
|
10
|
-
}
|
|
11
|
-
this.xhr = new XMLHttpRequest();
|
|
12
|
-
var self = this;
|
|
13
|
-
this.xhr.open('GET', this.options.url + this.buildQueryString(this.getParams()), true);
|
|
14
|
-
|
|
15
|
-
this.xhr.onload = function(e) {
|
|
16
|
-
self.fire('ajax:return');
|
|
17
|
-
if (this.status === 200) {
|
|
18
|
-
if (callback) {
|
|
19
|
-
var raw = this.response;
|
|
20
|
-
raw = JSON.parse(raw);
|
|
21
|
-
callback.call(thisobj || this, raw);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
delete this.xhr;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
this.fire('ajax:send');
|
|
28
|
-
this.xhr.send();
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
buildQueryString: function (params) {
|
|
32
|
-
var queryString = [];
|
|
33
|
-
for (var key in params) {
|
|
34
|
-
if (params[key]) {
|
|
35
|
-
queryString.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return queryString.join('&');
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
featureToPopupContent: function (feature) {
|
|
42
|
-
var container = L.DomUtil.create('div', 'leaflet-photon-popup'),
|
|
43
|
-
title = L.DomUtil.create('h3', '', container);
|
|
44
|
-
title.innerHTML = feature.properties.label;
|
|
45
|
-
return container;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
L.PhotonBaseSearch = L.PhotonBase.extend({
|
|
52
|
-
|
|
53
|
-
includes: ((typeof L.Evented !== 'undefined' && L.Evented.prototype) || L.Mixin.Events),
|
|
54
|
-
|
|
55
|
-
options: {
|
|
56
|
-
url: 'https://photon.komoot.io/api/?',
|
|
57
|
-
placeholder: 'Start typing...',
|
|
58
|
-
minChar: 3,
|
|
59
|
-
limit: 5,
|
|
60
|
-
submitDelay: 300,
|
|
61
|
-
includePosition: true,
|
|
62
|
-
bbox: null,
|
|
63
|
-
noResultLabel: 'No result',
|
|
64
|
-
feedbackEmail: 'photon@komoot.de', // Set to null to remove feedback box
|
|
65
|
-
feedbackLabel: 'Feedback'
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
CACHE: '',
|
|
69
|
-
RESULTS: [],
|
|
70
|
-
KEYS: {
|
|
71
|
-
LEFT: 37,
|
|
72
|
-
UP: 38,
|
|
73
|
-
RIGHT: 39,
|
|
74
|
-
DOWN: 40,
|
|
75
|
-
TAB: 9,
|
|
76
|
-
RETURN: 13,
|
|
77
|
-
ESC: 27,
|
|
78
|
-
APPLE: 91,
|
|
79
|
-
SHIFT: 16,
|
|
80
|
-
ALT: 17,
|
|
81
|
-
CTRL: 18
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
initialize: function (input, options) {
|
|
85
|
-
this.input = input;
|
|
86
|
-
L.setOptions(this, options);
|
|
87
|
-
var CURRENT = null;
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
Object.defineProperty(this, 'CURRENT', {
|
|
91
|
-
get: function () {
|
|
92
|
-
return CURRENT;
|
|
93
|
-
},
|
|
94
|
-
set: function (index) {
|
|
95
|
-
if (typeof index === 'object') {
|
|
96
|
-
index = this.resultToIndex(index);
|
|
97
|
-
}
|
|
98
|
-
CURRENT = index;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
} catch (e) {
|
|
102
|
-
// Hello IE8
|
|
103
|
-
}
|
|
104
|
-
this.input.type = L.Browser.ie ? 'text' : 'search';
|
|
105
|
-
this.input.placeholder = this.options.placeholder;
|
|
106
|
-
this.input.autocomplete = 'off';
|
|
107
|
-
this.input.autocorrect = 'off';
|
|
108
|
-
L.DomEvent.disableClickPropagation(this.input);
|
|
109
|
-
|
|
110
|
-
L.DomEvent.on(this.input, 'keydown', this.onKeyDown, this);
|
|
111
|
-
L.DomEvent.on(this.input, 'input', this.onInput, this);
|
|
112
|
-
L.DomEvent.on(this.input, 'blur', this.onBlur, this);
|
|
113
|
-
L.DomEvent.on(this.input, 'focus', this.onFocus, this);
|
|
114
|
-
this.createResultsContainer();
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
createResultsContainer: function () {
|
|
118
|
-
this.resultsContainer = this.options.resultsContainer || L.DomUtil.create('ul', 'photon-autocomplete', document.querySelector('body'));
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
resizeContainer: function()
|
|
122
|
-
{
|
|
123
|
-
var l = this.getLeft(this.input);
|
|
124
|
-
var t = this.getTop(this.input) + this.input.offsetHeight;
|
|
125
|
-
this.resultsContainer.style.left = l + 'px';
|
|
126
|
-
this.resultsContainer.style.top = t + 'px';
|
|
127
|
-
var width = this.options.width ? this.options.width : this.input.offsetWidth - 2;
|
|
128
|
-
this.resultsContainer.style.width = width + 'px';
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
onKeyDown: function (e) {
|
|
132
|
-
switch (e.keyCode) {
|
|
133
|
-
case this.KEYS.TAB:
|
|
134
|
-
if(this.CURRENT !== null)
|
|
135
|
-
{
|
|
136
|
-
this.setChoice();
|
|
137
|
-
}
|
|
138
|
-
L.DomEvent.stop(e);
|
|
139
|
-
break;
|
|
140
|
-
case this.KEYS.RETURN:
|
|
141
|
-
L.DomEvent.stop(e);
|
|
142
|
-
this.setChoice();
|
|
143
|
-
break;
|
|
144
|
-
case this.KEYS.ESC:
|
|
145
|
-
L.DomEvent.stop(e);
|
|
146
|
-
this.hide();
|
|
147
|
-
this.input.blur();
|
|
148
|
-
break;
|
|
149
|
-
case this.KEYS.DOWN:
|
|
150
|
-
if(this.RESULTS.length > 0) {
|
|
151
|
-
if(this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) { // what if one resutl?
|
|
152
|
-
this.CURRENT++;
|
|
153
|
-
this.highlight();
|
|
154
|
-
}
|
|
155
|
-
else if(this.CURRENT === null) {
|
|
156
|
-
this.CURRENT = 0;
|
|
157
|
-
this.highlight();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
|
-
case this.KEYS.UP:
|
|
162
|
-
if(this.CURRENT !== null) {
|
|
163
|
-
L.DomEvent.stop(e);
|
|
164
|
-
}
|
|
165
|
-
if(this.RESULTS.length > 0) {
|
|
166
|
-
if(this.CURRENT > 0) {
|
|
167
|
-
this.CURRENT--;
|
|
168
|
-
this.highlight();
|
|
169
|
-
}
|
|
170
|
-
else if(this.CURRENT === 0) {
|
|
171
|
-
this.CURRENT = null;
|
|
172
|
-
this.highlight();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
onInput: function (e) {
|
|
180
|
-
if (typeof this.submitDelay === 'number') {
|
|
181
|
-
window.clearTimeout(this.submitDelay);
|
|
182
|
-
delete this.submitDelay;
|
|
183
|
-
}
|
|
184
|
-
this.submitDelay = window.setTimeout(L.Util.bind(this.search, this), this.options.submitDelay);
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
onBlur: function (e) {
|
|
188
|
-
this.fire('blur');
|
|
189
|
-
var self = this;
|
|
190
|
-
setTimeout(function () {
|
|
191
|
-
self.hide();
|
|
192
|
-
}, 100);
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
onFocus: function (e) {
|
|
196
|
-
this.fire('focus');
|
|
197
|
-
this.input.select();
|
|
198
|
-
this.search(); // In case we have a value from a previous search.
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
clear: function () {
|
|
202
|
-
this.RESULTS = [];
|
|
203
|
-
this.CURRENT = null;
|
|
204
|
-
this.CACHE = '';
|
|
205
|
-
this.resultsContainer.innerHTML = '';
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
hide: function() {
|
|
209
|
-
this.fire('hide');
|
|
210
|
-
this.clear();
|
|
211
|
-
this.resultsContainer.style.display = 'none';
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
setChoice: function (choice) {
|
|
215
|
-
choice = choice || this.RESULTS[this.CURRENT];
|
|
216
|
-
if (choice) {
|
|
217
|
-
this.hide();
|
|
218
|
-
this.fire('selected', {choice: choice.feature});
|
|
219
|
-
this.onSelected(choice.feature);
|
|
220
|
-
this.input.value = '';
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
search: function() {
|
|
225
|
-
var val = this.input.value;
|
|
226
|
-
var minChar = typeof this.options.minChar === 'function' ? this.options.minChar(val) : val.length >= this.options.minChar;
|
|
227
|
-
if (!val || !minChar) return this.clear();
|
|
228
|
-
if(val + '' === this.CACHE + '') return;
|
|
229
|
-
else this.CACHE = val;
|
|
230
|
-
this._doSearch();
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
_doSearch: function () {
|
|
234
|
-
this.ajax(this.handleResults, this);
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
_onSelected: function (feature) {
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
onSelected: function (choice) {
|
|
241
|
-
return (this.options.onSelected || this._onSelected).call(this, choice);
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
_formatResult: function (feature, el) {
|
|
245
|
-
var title = L.DomUtil.create('strong', '', el),
|
|
246
|
-
detailsContainer = L.DomUtil.create('small', '', el),
|
|
247
|
-
details = [],
|
|
248
|
-
type = this.formatType(feature);
|
|
249
|
-
if (feature.properties.name) {
|
|
250
|
-
title.innerHTML = feature.properties.name;
|
|
251
|
-
} else if (feature.properties.housenumber) {
|
|
252
|
-
title.innerHTML = feature.properties.housenumber;
|
|
253
|
-
if (feature.properties.street) {
|
|
254
|
-
title.innerHTML += ' ' + feature.properties.street;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (type) details.push(type);
|
|
258
|
-
if (feature.properties.city && feature.properties.city !== feature.properties.name) {
|
|
259
|
-
details.push(feature.properties.city);
|
|
260
|
-
}
|
|
261
|
-
if (feature.properties.state && feature.properties.state !== feature.properties.name) {
|
|
262
|
-
details.push(feature.properties.state);
|
|
263
|
-
}
|
|
264
|
-
if (feature.properties.country) details.push(feature.properties.country);
|
|
265
|
-
detailsContainer.innerHTML = details.join(', ');
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
formatResult: function (feature, el) {
|
|
269
|
-
return (this.options.formatResult || this._formatResult).call(this, feature, el);
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
formatType: function (feature) {
|
|
273
|
-
return (this.options.formatType || this._formatType).call(this, feature);
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
_formatType: function (feature) {
|
|
277
|
-
return feature.properties.osm_value === 'yes'
|
|
278
|
-
? feature.properties.osm_key
|
|
279
|
-
: feature.properties.osm_value;
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
createResult: function (feature) {
|
|
283
|
-
var el = L.DomUtil.create('li', '', this.resultsContainer);
|
|
284
|
-
this.formatResult(feature, el);
|
|
285
|
-
var result = {
|
|
286
|
-
feature: feature,
|
|
287
|
-
el: el
|
|
288
|
-
};
|
|
289
|
-
// Touch handling needed
|
|
290
|
-
L.DomEvent.on(el, 'mouseover', function (e) {
|
|
291
|
-
this.CURRENT = result;
|
|
292
|
-
this.highlight();
|
|
293
|
-
}, this);
|
|
294
|
-
L.DomEvent.on(el, 'mousedown', function (e) {
|
|
295
|
-
this.setChoice();
|
|
296
|
-
}, this);
|
|
297
|
-
return result;
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
resultToIndex: function (result) {
|
|
301
|
-
var out = null;
|
|
302
|
-
this.forEach(this.RESULTS, function (item, index) {
|
|
303
|
-
if (item === result) {
|
|
304
|
-
out = index;
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
return out;
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
handleResults: function(geojson) {
|
|
312
|
-
var self = this;
|
|
313
|
-
this.clear();
|
|
314
|
-
this.resultsContainer.style.display = 'block';
|
|
315
|
-
this.resizeContainer();
|
|
316
|
-
this.forEach(geojson.features, function (feature) {
|
|
317
|
-
self.RESULTS.push(self.createResult(feature));
|
|
318
|
-
});
|
|
319
|
-
if (geojson.features.length === 0) {
|
|
320
|
-
var noresult = L.DomUtil.create('li', 'photon-no-result', this.resultsContainer);
|
|
321
|
-
noresult.innerHTML = this.options.noResultLabel;
|
|
322
|
-
}
|
|
323
|
-
if (this.options.feedbackEmail) {
|
|
324
|
-
var feedback = L.DomUtil.create('a', 'photon-feedback', this.resultsContainer);
|
|
325
|
-
feedback.href = 'mailto:' + this.options.feedbackEmail;
|
|
326
|
-
feedback.innerHTML = this.options.feedbackLabel;
|
|
327
|
-
}
|
|
328
|
-
this.CURRENT = 0;
|
|
329
|
-
this.highlight();
|
|
330
|
-
if (this.options.resultsHandler) {
|
|
331
|
-
this.options.resultsHandler(geojson);
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
highlight: function () {
|
|
336
|
-
var self = this;
|
|
337
|
-
this.forEach(this.RESULTS, function (item, index) {
|
|
338
|
-
if (index === self.CURRENT) {
|
|
339
|
-
L.DomUtil.addClass(item.el, 'on');
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
L.DomUtil.removeClass(item.el, 'on');
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
|
|
347
|
-
getLeft: function (el) {
|
|
348
|
-
var tmp = el.offsetLeft;
|
|
349
|
-
el = el.offsetParent;
|
|
350
|
-
while(el) {
|
|
351
|
-
tmp += el.offsetLeft;
|
|
352
|
-
el = el.offsetParent;
|
|
353
|
-
}
|
|
354
|
-
return tmp;
|
|
355
|
-
},
|
|
356
|
-
|
|
357
|
-
getTop: function (el) {
|
|
358
|
-
var tmp = el.offsetTop;
|
|
359
|
-
el = el.offsetParent;
|
|
360
|
-
while(el) {
|
|
361
|
-
tmp += el.offsetTop;
|
|
362
|
-
el = el.offsetParent;
|
|
363
|
-
}
|
|
364
|
-
return tmp;
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
getParams: function () {
|
|
368
|
-
return {
|
|
369
|
-
q: this.CACHE,
|
|
370
|
-
lang: this.options.lang,
|
|
371
|
-
limit: this.options.limit,
|
|
372
|
-
osm_tag: this.options.osm_tag
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
L.PhotonSearch = L.PhotonBaseSearch.extend({
|
|
379
|
-
|
|
380
|
-
initialize: function (map, input, options) {
|
|
381
|
-
this.map = map;
|
|
382
|
-
L.PhotonBaseSearch.prototype.initialize.call(this, input, options);
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
_onSelected: function (feature) {
|
|
386
|
-
this.map.setView([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], 16);
|
|
387
|
-
},
|
|
388
|
-
|
|
389
|
-
getParams: function () {
|
|
390
|
-
var params = L.PhotonBaseSearch.prototype.getParams.call(this);
|
|
391
|
-
if (this.options.includePosition) {
|
|
392
|
-
params.lat = this.map.getCenter().lat;
|
|
393
|
-
params.lon = this.map.getCenter().lng;
|
|
394
|
-
if (this.options.location_bias_scale) {
|
|
395
|
-
params.location_bias_scale = this.options.location_bias_scale;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (this.options.bbox && this.options.bbox.length === 4) {
|
|
399
|
-
params.bbox = this.options.bbox.join(',');
|
|
400
|
-
}
|
|
401
|
-
return params;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
L.Control.Photon = L.Control.extend({
|
|
407
|
-
|
|
408
|
-
includes: ((typeof L.Evented !== 'undefined' && L.Evented.prototype) || L.Mixin.Events),
|
|
409
|
-
|
|
410
|
-
onAdd: function (map, options) {
|
|
411
|
-
this.map = map;
|
|
412
|
-
this.container = L.DomUtil.create('div', 'leaflet-photon');
|
|
413
|
-
|
|
414
|
-
this.options = L.Util.extend(this.options, options);
|
|
415
|
-
|
|
416
|
-
this.input = L.DomUtil.create('input', 'photon-input', this.container);
|
|
417
|
-
this.search = new L.PhotonSearch(map, this.input, this.options);
|
|
418
|
-
this.search.on('blur', this.forwardEvent, this);
|
|
419
|
-
this.search.on('focus', this.forwardEvent, this);
|
|
420
|
-
this.search.on('hide', this.forwardEvent, this);
|
|
421
|
-
this.search.on('selected', this.forwardEvent, this);
|
|
422
|
-
this.search.on('ajax:send', this.forwardEvent, this);
|
|
423
|
-
this.search.on('ajax:return', this.forwardEvent, this);
|
|
424
|
-
return this.container;
|
|
425
|
-
},
|
|
426
|
-
|
|
427
|
-
// TODO onRemove
|
|
428
|
-
|
|
429
|
-
forwardEvent: function (e) {
|
|
430
|
-
this.fire(e.type, e);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
L.control.photon = function(options) {
|
|
436
|
-
return new L.Control.Photon(options);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
L.Map.addInitHook(function () {
|
|
440
|
-
if (this.options.photonControl) {
|
|
441
|
-
this.photonControl = new L.Control.Photon(this.options.photonControlOptions || {});
|
|
442
|
-
this.addControl(this.photonControl);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
L.PhotonReverse = L.PhotonBase.extend({
|
|
447
|
-
|
|
448
|
-
includes: ((typeof L.Evented !== 'undefined' && L.Evented.prototype) || L.Mixin.Events),
|
|
449
|
-
|
|
450
|
-
options: {
|
|
451
|
-
url: 'https://photon.komoot.io/reverse/?',
|
|
452
|
-
limit: 1,
|
|
453
|
-
handleResults: null
|
|
454
|
-
},
|
|
455
|
-
|
|
456
|
-
initialize: function (options) {
|
|
457
|
-
L.setOptions(this, options);
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
doReverse: function (latlng) {
|
|
461
|
-
latlng = L.latLng(latlng);
|
|
462
|
-
this.fire('reverse', {latlng: latlng});
|
|
463
|
-
this.latlng = latlng;
|
|
464
|
-
this.ajax(this.handleResults, this);
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
_handleResults: function (data) {
|
|
468
|
-
/*eslint-disable no-console */
|
|
469
|
-
console.log(data);
|
|
470
|
-
/*eslint-enable no-alert */
|
|
471
|
-
},
|
|
472
|
-
|
|
473
|
-
handleResults: function (data) {
|
|
474
|
-
return (this.options.handleResults || this._handleResults).call(this, data);
|
|
475
|
-
},
|
|
476
|
-
|
|
477
|
-
getParams: function () {
|
|
478
|
-
return {
|
|
479
|
-
lang: this.options.lang,
|
|
480
|
-
limit: this.options.limit,
|
|
481
|
-
lat: this.latlng.lat,
|
|
482
|
-
lon: this.latlng.lng,
|
|
483
|
-
osm_tag: this.options.osm_tag
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
});
|
|
File without changes
|
|
File without changes
|