Save new folder

This commit is contained in:
2025-11-09 10:02:18 +01:00
commit 5c733eac6b
21738 changed files with 4477854 additions and 0 deletions

View File

@ -0,0 +1,38 @@
.leaflet-control-geocoder a {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-control-geocoder {
box-shadow: 0 1px 7px #999;
background: #f8f8f9;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
}
.leaflet-control-geocoder a {
background-image: url(images/geocoder.png);
width: 36px;
height: 36px;
}
.leaflet-touch .leaflet-control-geocoder a {
width: 44px;
height: 44px;
}
.leaflet-control-geocoder .leaflet-control-geocoder-form,
.leaflet-control-geocoder-expanded .leaflet-control-geocoder-toggle {
display: none;
}
.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form {
display: block;
position: relative;
}
.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form {
padding: 5px;
}

View File

@ -0,0 +1,197 @@
if (typeof console == "undefined") {
this.console = { log: function (msg) { /* do nothing since it would otherwise break IE */} };
}
L.Control.OSMGeocoder = L.Control.extend({
options: {
collapsed: true,
position: 'topright',
text: 'Locate',
placeholder: '',
bounds: null, // L.LatLngBounds
email: null, // String
callback: function (results) {
if (results.length == 0) {
console.log("ERROR: didn't find a result");
return;
}
var bbox = results[0].boundingbox,
first = new L.LatLng(bbox[0], bbox[2]),
second = new L.LatLng(bbox[1], bbox[3]),
bounds = new L.LatLngBounds([first, second]);
this._map.fitBounds(bounds);
}
},
_callbackId: 0,
initialize: function (options) {
L.Util.setOptions(this, options);
},
onAdd: function (map) {
this._map = map;
var className = 'leaflet-control-geocoder',
container = this._container = L.DomUtil.create('div', className);
L.DomEvent.disableClickPropagation(container);
var form = this._form = L.DomUtil.create('form', className + '-form');
var input = this._input = document.createElement('input');
input.type = "text";
input.placeholder = this.options.placeholder || '';
var submit = document.createElement('input');
submit.type = "submit";
submit.value = this.options.text;
form.appendChild(input);
form.appendChild(submit);
L.DomEvent.addListener(form, 'submit', this._geocode, this);
if (this.options.collapsed) {
L.DomEvent.addListener(container, 'mouseover', this._expand, this);
L.DomEvent.addListener(container, 'mouseout', this._collapse, this);
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
link.href = '#';
link.title = 'Nominatim Geocoder';
L.DomEvent.addListener(link, L.Browser.touch ? 'click' : 'focus', this._expand, this);
this._map.on('movestart', this._collapse, this);
} else {
this._expand();
}
container.appendChild(form);
return container;
},
/* helper functions for cordinate extraction */
_createSearchResult : function(lat, lon) {
//creates an position description similar to the result of a Nominatim search
var diff = 0.005;
var result = [];
result[0] = {};
result[0]["boundingbox"] = [parseFloat(lat)-diff,parseFloat(lat)+diff,parseFloat(lon)-diff,parseFloat(lon)+diff];
result[0]["class"]="boundary";
result[0]["display_name"]="Position: "+lat+" "+lon;
result[0]["lat"] = lat;
result[0]["lon"] = lon;
return result;
},
_isLatLon : function (q) {
//"lon lat" => xx.xxx x.xxxxx
var re = /(-?\d+\.\d+)\s(-?\d+\.\d+)/;
var m = re.exec(q);
if (m != undefined) return m;
//lat...xx.xxx...lon...x.xxxxx
re = /lat\D*(-?\d+\.\d+)\D*lon\D*(-?\d+\.\d+)/;
m = re.exec(q);
//showRegExpResult(m);
if (m != undefined) return m;
else return null;
},
_isLatLon_decMin : function (q) {
console.log("is LatLon?: "+q);
//N 53° 13.785' E 010° 23.887'
//re = /[NS]\s*(\d+)\D*(\d+\.\d+).?\s*[EW]\s*(\d+)\D*(\d+\.\d+)\D*/;
re = /([ns])\s*(\d+)\D*(\d+\.\d+).?\s*([ew])\s*(\d+)\D*(\d+\.\d+)/i;
m = re.exec(q.toLowerCase());
//showRegExpResult(m);
if ((m != undefined)) return m;
else return null;
// +- dec min +- dec min
},
_geocode : function (event) {
L.DomEvent.preventDefault(event);
var q = this._input.value;
//try to find corrdinates
if (this._isLatLon(q) != null)
{
var m = this._isLatLon(q);
console.log("LatLon: "+m[1]+" "+m[2]);
//m = {lon, lat}
this.options.callback.call(this, this._createSearchResult(m[1],m[2]));
return;
}
else if (this._isLatLon_decMin(q) != null)
{
var m = this._isLatLon_decMin(q);
//m: [ns, lat dec, lat min, ew, lon dec, lon min]
var temp = new Array();
temp['n'] = 1;
temp['s'] = -1;
temp['e'] = 1;
temp['w'] = -1;
this.options.callback.call(this,this._createSearchResult(
temp[m[1]]*(Number(m[2]) + m[3]/60),
temp[m[4]]*(Number(m[5]) + m[6]/60)
));
return;
}
//and now Nominatim
//http://wiki.openstreetmap.org/wiki/Nominatim
console.log(this._callbackId);
window[("_l_osmgeocoder_"+this._callbackId)] = L.Util.bind(this.options.callback, this);
/* Set up params to send to Nominatim */
var params = {
// Defaults
q: this._input.value,
json_callback : ("_l_osmgeocoder_"+this._callbackId++),
format: 'json'
};
if (this.options.bounds && this.options.bounds != null) {
if( this.options.bounds instanceof L.LatLngBounds ) {
params.viewbox = this.options.bounds.toBBoxString();
params.bounded = 1;
}
else {
console.log('bounds must be of type L.LatLngBounds');
return;
}
}
if (this.options.email && this.options.email != null) {
if (typeof this.options.email == 'string') {
params.email = this.options.email;
}
else{
console.log('email must be a string');
}
}
var protocol = location.protocol;
if (protocol == "file:") protocol = "https:";
var url = protocol + "//nominatim.openstreetmap.org/search" + L.Util.getParamString(params),
script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.id = this._callbackId;
document.getElementsByTagName("head")[0].appendChild(script);
},
_expand: function () {
L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-expanded');
},
_collapse: function () {
this._container.className = this._container.className.replace(' leaflet-control-geocoder-expanded', '');
}
});

View File

@ -0,0 +1 @@
.leaflet-control-geocoder a{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-control-geocoder{box-shadow:0 1px 7px #999;background:#f8f8f9;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.leaflet-control-geocoder a{background-image:url(images/geocoder.png);width:36px;height:36px}.leaflet-touch .leaflet-control-geocoder a{width:44px;height:44px}.leaflet-control-geocoder .leaflet-control-geocoder-form,.leaflet-control-geocoder-expanded .leaflet-control-geocoder-toggle{display:none}.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form{display:block;position:relative}.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form{padding:5px}

View File

@ -0,0 +1 @@
if(typeof console=="undefined"){this.console={log:function(e){}}}L.Control.OSMGeocoder=L.Control.extend({options:{collapsed:true,position:"topright",text:"Locate",placeholder:"",bounds:null,email:null,callback:function(e){if(e.length==0){console.log("ERROR: didn't find a result");return}var t=e[0].boundingbox,o=new L.LatLng(t[0],t[2]),n=new L.LatLng(t[1],t[3]),i=new L.LatLngBounds([o,n]);this._map.fitBounds(i)}},_callbackId:0,initialize:function(e){L.Util.setOptions(this,e)},onAdd:function(e){this._map=e;var t="leaflet-control-geocoder",o=this._container=L.DomUtil.create("div",t);L.DomEvent.disableClickPropagation(o);var n=this._form=L.DomUtil.create("form",t+"-form");var i=this._input=document.createElement("input");i.type="text";i.placeholder=this.options.placeholder||"";var s=document.createElement("input");s.type="submit";s.value=this.options.text;n.appendChild(i);n.appendChild(s);L.DomEvent.addListener(n,"submit",this._geocode,this);if(this.options.collapsed){L.DomEvent.addListener(o,"mouseover",this._expand,this);L.DomEvent.addListener(o,"mouseout",this._collapse,this);var a=this._layersLink=L.DomUtil.create("a",t+"-toggle",o);a.href="#";a.title="Nominatim Geocoder";L.DomEvent.addListener(a,L.Browser.touch?"click":"focus",this._expand,this);this._map.on("movestart",this._collapse,this)}else{this._expand()}o.appendChild(n);return o},_createSearchResult:function(e,t){var o=.005;var n=[];n[0]={};n[0]["boundingbox"]=[parseFloat(e)-o,parseFloat(e)+o,parseFloat(t)-o,parseFloat(t)+o];n[0]["class"]="boundary";n[0]["display_name"]="Position: "+e+" "+t;n[0]["lat"]=e;n[0]["lon"]=t;return n},_isLatLon:function(e){var t=/(-?\d+\.\d+)\s(-?\d+\.\d+)/;var o=t.exec(e);if(o!=undefined)return o;t=/lat\D*(-?\d+\.\d+)\D*lon\D*(-?\d+\.\d+)/;o=t.exec(e);if(o!=undefined)return o;else return null},_isLatLon_decMin:function(e){console.log("is LatLon?: "+e);re=/([ns])\s*(\d+)\D*(\d+\.\d+).?\s*([ew])\s*(\d+)\D*(\d+\.\d+)/i;m=re.exec(e.toLowerCase());if(m!=undefined)return m;else return null},_geocode:function(e){L.DomEvent.preventDefault(e);var t=this._input.value;if(this._isLatLon(t)!=null){var o=this._isLatLon(t);console.log("LatLon: "+o[1]+" "+o[2]);this.options.callback.call(this,this._createSearchResult(o[1],o[2]));return}else if(this._isLatLon_decMin(t)!=null){var o=this._isLatLon_decMin(t);var n=new Array;n["n"]=1;n["s"]=-1;n["e"]=1;n["w"]=-1;this.options.callback.call(this,this._createSearchResult(n[o[1]]*(Number(o[2])+o[3]/60),n[o[4]]*(Number(o[5])+o[6]/60)));return}console.log(this._callbackId);window["_l_osmgeocoder_"+this._callbackId]=L.Util.bind(this.options.callback,this);var i={q:this._input.value,json_callback:"_l_osmgeocoder_"+this._callbackId++,format:"json"};if(this.options.bounds&&this.options.bounds!=null){if(this.options.bounds instanceof L.LatLngBounds){i.viewbox=this.options.bounds.toBBoxString();i.bounded=1}else{console.log("bounds must be of type L.LatLngBounds");return}}if(this.options.email&&this.options.email!=null){if(typeof this.options.email=="string"){i.email=this.options.email}else{console.log("email must be a string")}}var s=location.protocol;if(s=="file:")s="https:";var a=s+"//nominatim.openstreetmap.org/search"+L.Util.getParamString(i),l=document.createElement("script");l.type="text/javascript";l.src=a;l.id=this._callbackId;document.getElementsByTagName("head")[0].appendChild(l)},_expand:function(){L.DomUtil.addClass(this._container,"leaflet-control-geocoder-expanded")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-geocoder-expanded","")}});

View File

@ -0,0 +1,23 @@
Copyright (c) 2012 sa3m (https://github.com/sa3m)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB