summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-02-27 13:18:05 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-02-27 13:18:05 +0100
commit7cf5c45341fad7c422364e80d87a86ecceeda144 (patch)
tree533a6edb0c8bc7fb297aa0d598c6800bd5f6e390 /threads.js
parent3d4a49c84cd5b01384e12424b4c5f347bd13f7ff (diff)
downloadsnap-yow-7cf5c45341fad7c422364e80d87a86ecceeda144.tar.gz
snap-yow-7cf5c45341fad7c422364e80d87a86ecceeda144.zip
add "my location" block and a nominatim search block
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/threads.js b/threads.js
index fab05a0..dfd19be 100644
--- a/threads.js
+++ b/threads.js
@@ -2638,6 +2638,33 @@ Process.prototype.addMarker = function (pos) {
L.marker(pos.contents).addTo(window.map);
};
+Process.prototype.findLocation = function (searchString) {
+ var myself = this;
+
+ if (!myself.context.jsonpScript) {
+ window.OSM_JSONP_Callback = function (data) {
+ myself.context.json = data;
+ window.OSM_JSONP_Callback = undefined;
+ };
+ myself.context.jsonpScript = document.createElement('script');
+ myself.context.jsonpScript.src =
+ 'https://nominatim.openstreetmap.org/search'
+ + '?format=json&json_callback=OSM_JSONP_Callback'
+ + '&addressdetails=0&limit=1'
+ + '&q=' + myself.inputOption(searchString);
+ document.getElementsByTagName('HEAD')[0]
+ .appendChild(myself.context.jsonpScript);
+ } else {
+ if (myself.context.json) {
+ return new List([myself.context.json[0].lat,
+ myself.context.json[0].lon]);
+ }
+ }
+
+ this.pushContext('doYield');
+ this.pushContext();
+}
+
// Process Dates and times in Snap
// Map block options to built-in functions
var dateMap = {