Inital commit

This commit is contained in:
grey committed 2022-03-06 18:36:36 +01:00
commit bedd69436b
175 files changed
+9965

No files matched your search

@@ -0,0 +1,9 @@
/*!
* LeafletSearch 1.0.1
* (c) 2021 Sjaak Priester, Amsterdam
* MIT License
* https://github.com/sjaakp/leaflet-search
* https://sjaakpriester.nl
*/
!function(){"use strict";!function(t){if(!t||"undefined"==typeof window)return;const e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e)}(".geo-search svg{display:block;width:100%;height:100%;position:relative}.geo-search input{transition:width .4s;width:0;padding:2px 0;border:solid #888;border-width:1px 0;outline:0}.geo-search.open input{width:15em;padding:2px 2px;border-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}.geo-search button{background-color:#fff;border:none;border:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000;background-position:50% 50%;background-repeat:no-repeat;overflow:hidden;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-left-radius:4px;border-bottom-right-radius:4px;display:block}.geo-search button:hover{background-color:#ddd}"),L.geo={Geocoder:L.Class.extend({initialize:function(t,e){this._map=t,L.setOptions(this,e)},constructUrl:function(t,e){void 0===e&&(e={});var n=Object.assign({},this.options,e),o=new URL(t);for(var r in n)o.searchParams.set(r,n[r]);return o},fetchJson:function(t){return fetch(t.href).then((function(t){return t.json()}))},placeMarker:function(t,e,n){this._map.placeMarker(t,e,n)},fire:function(t){this._map.fire(t)},suggest:function(t,e){},lookup:function(t){}})},L.geo.Nominatim=L.geo.Geocoder.extend({url:"https://nominatim.openstreetmap.org/",mark:function(t){var e=L.latLng(t.lat,t.lon),n=t.boundingbox,o=L.latLngBounds([n[0],n[2]],[n[1],n[3]]);this.placeMarker(e,o,t)},search:function(t){var e=this.constructUrl(this.url+"search",{format:"json",q:t});return this.fetchJson(e)},suggest:function(t,e){var n=this;this.search(t).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.osm_type.charAt(0).toUpperCase()+e.osm_id+'">'+e.display_name+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){var e=this,n=this.constructUrl(this.url+"reverse",{format:"json",osm_type:t.charAt(0),osm_id:t.slice(1)});this.fetchJson(n).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))},geocode:function(t){var e=this;this.search(t).then((function(t){if(t.length<1)throw"notfound";return t[0]})).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))}}),L.geo.GeoNames=L.geo.Geocoder.extend({url:"http://api.geonames.org/search",fetchGeonames:function(t){return this.fetchJson(t).then((function(t){var e=t.geonames;if(!e||e.length<1)throw"notfound";return e}))},mark:function(t){var e=L.latLng(t.lat,t.lng),n=t.bbox,o=L.latLngBounds([n.north,n.west],[n.south,n.east]);this.placeMarker(e,o,t)},suggest:function(t,e){var n=this,o=this.constructUrl(this.url,{q:t,type:"json",style:"short"});this.fetchGeonames(o).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.geonameId+'">'+e.name+"&emsp;"+e.countryCode+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){var e=this,n=this.constructUrl("http://api.geonames.org/getJSON",{geonameId:t});this.fetchJson(n).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))},geocode:function(t){var e=this,n=this.constructUrl(this.url,{q:t,inclBbox:!0});this.fetchGeonames(n).then((function(t){return t.shift()})).then((function(t){return e.mark(t)})).catch((function(t){return e.fire(t)}))}}),L.geo.Here=L.geo.Geocoder.extend({mark:function(t){var e=t.displayPosition,n=L.latLng(e.latitude,e.longitude),o=t.mapView,r=o.topLeft,i=o.bottomRight,s=L.latLngBounds([r.latitude,i.longitude],[i.latitude,r.longitude]);this.placeMarker(n,s,t)},fetchData:function(t){var e=this;t.jsonattributes=1;var n=this.constructUrl("https://geocoder.ls.hereapi.com/6.2/geocode.json",t);this.fetchJson(n).then((function(t){return t.response.view.shift().result.shift()})).then((function(t){return e.mark(t.location)})).catch((function(t){return e.fire(t)}))},suggest:function(t,e){var n=this,o=this.constructUrl("https://autocomplete.geocoder.ls.hereapi.com/6.2/suggest.json",{query:t});this.fetchJson(o).then((function(t){return t.suggestions})).then((function(t){e.innerHTML=t.reduce((function(t,e){return t+'<option data-id="'+e.locationId+'">'+e.label+"</option>"}),"")})).catch((function(t){return n.fire(t)}))},lookup:function(t){this.fetchData({locationid:t})},geocode:function(t){this.fetchData({searchtext:t})}}),L.geo.TomTom=L.geo.Geocoder.extend({url:"https://api.tomtom.com/search/2/geocode/",suggestions:[],datalist:null,mark:function(t){var e=t.position,n=L.latLng(e.lat,e.lon),o=t.viewport,r=o.topLeftPoint,i=o.btmRightPoint,s=L.latLngBounds([r.lat,i.lon],[i.lat,r.lon]);this.placeMarker(n,s,t)},fetchResults:function(t,e){void 0===e&&(e={});var n=encodeURIComponent(t),o=this.constructUrl(""+this.url+n+".json",e);return this.fetchJson(o).then((function(t){if(t.summary.numResults<1)throw"notfound";return t.results}))},suggest:function(t,e){var n=this;thiLine truncated
//# sourceMappingURL=leaflet-search.js.map
@@ -0,0 +1 @@
{"version":3,"file":"leaflet-search.js","sources":["../src/geo.js","../src/providers/nominatim.js","../src/providers/geonames.js","../src/providers/here.js","../src/providers/tomtom.js","../src/providers/kadaster.js","../node_modules/lodash.debounce/index.js","../src/index.js"],"sourcesContent":["/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\nL.geo = {\r\n Geocoder: L.Class.extend({\r\n initialize: function (map, options) {\r\n this._map = map;\r\n L.setOptions(this, options);\r\n },\r\n\r\n constructUrl(text, options = {}) {\r\n const opts = Object.assign({}, this.options, options),\r\n url = new URL(text);\r\n for (const k in opts) {\r\n url.searchParams.set(k, opts[k]);\r\n }\r\n return url;\r\n },\r\n\r\n fetchJson(url) {\r\n return fetch(url.href)\r\n .then(response => response.json())\r\n },\r\n\r\n placeMarker(latlng, bbox, place) {\r\n this._map.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n fire(err) {\r\n this._map.fire(err);\r\n },\r\n\r\n suggest(address, datalist) {\r\n },\r\n\r\n lookup(id) {\r\n }\r\n })\r\n};\r\n","\r\n/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\n/**\r\n * @link https://nominatim.org/release-docs/develop/api/Search/\r\n */\r\nL.geo.Nominatim = L.geo.Geocoder.extend({\r\n url: 'https://nominatim.openstreetmap.org/',\r\n\r\n mark(place) {\r\n const latlng = L.latLng(place.lat, place.lon),\r\n bb = place.boundingbox,\r\n bbox = L.latLngBounds([bb[0], bb[2]], [bb[1], bb[3]]);\r\n this.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n search(address) {\r\n const url = this.constructUrl(this.url + 'search', { format: 'json', q: address });\r\n return this.fetchJson(url)\r\n },\r\n\r\n suggest(address, datalist) {\r\n // const url = this.constructUrl(this.url + 'search', { format: 'json', q: address });\r\n this.search(address)\r\n .then(json => {\r\n // console.log(json);\r\n datalist.innerHTML = json.reduce((a, v) => a + `<option data-id=\"${v.osm_type.charAt(0).toUpperCase()}${v.osm_id}\">${v.display_name}</option>`, '');\r\n })\r\n .catch(error => this.fire(error));\r\n },\r\n\r\n lookup(id) {\r\n const url = this.constructUrl(this.url + 'reverse', {\r\n format: 'json',\r\n osm_type: id.charAt(0),\r\n osm_id: id.slice(1)\r\n });\r\n this.fetchJson(url)\r\n .then(json => this.mark(json))\r\n .catch(error => this.fire(error));\r\n },\r\n\r\n geocode(address) {\r\n // fetch('//nominatim.openstreetmap.org/search?format=json&q=' + encodeURIComponent(address))\r\n // .then(response => response.json())\r\n this.search(address)\r\n .then(json => {\r\n if (json.length < 1) throw('notfound');\r\n return json[0];\r\n })\r\n .then(place => this.mark(place))\r\n .catch(error => this.fire(error));\r\n }\r\n});\r\n","/**\r\n * sjaakp/leaflet-search\r\n * ----------\r\n * Search Control for Leaflet\r\n * Version 1.0.0\r\n * Copyright (c) 2020\r\n * Sjaak Priester, Amsterdam\r\n * MIT License\r\n * https://github.com/sjaakp/leaflet-search\r\n * https://sjaakpriester.nl\r\n */\r\n\r\n/**\r\n * Topological names only; no streets\r\n * @link http://www.geonames.org/export/geonames-search.html\r\n */\r\nL.geo.GeoNames = L.geo.Geocoder.extend({\r\n url: 'http://api.geonames.org/search', // no https!\r\n\r\n fetchGeonames(url) {\r\n return this.fetchJson(url)\r\n .then(json => {\r\n const geonames = json.geonames;\r\n if (! geonames || geonames.length < 1) throw 'notfound';\r\n return geonames;\r\n })\r\n },\r\n\r\n mark(place) {\r\n const latlng = L.latLng(place.lat, place.lng),\r\n bb = place.bbox,\r\n bbox = L.latLngBounds([bb.north, bb.west], [bb.south, bb.east]);\r\n this.placeMarker(latlng, bbox, place);\r\n },\r\n\r\n suggest(address, datalist) {\r\n const url = this.constructUrl(this.url, { q: address, type: 'json', style: 'short' });\r\n\r\n this.fetchGeonames(url)\r\n .then(geonames => {\r\n Line truncated