leaflet-control-geocoder
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -1,2 +0,2 @@ | ||
(function(u,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("leaflet")):typeof define=="function"&&define.amd?define(["exports","leaflet"],m):(u=typeof globalThis<"u"?globalThis:u||self,m(u["leaflet-control-geocoder"]={},u.L))})(this,function(u,m){"use strict";var pe=Object.defineProperty;var de=(u,m,_)=>m in u?pe(u,m,{enumerable:!0,configurable:!0,writable:!0,value:_}):u[m]=_;var p=(u,m,_)=>de(u,typeof m!="symbol"?m+"":m,_);function _(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const t=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(e,o,t.get?t:{enumerable:!0,get:()=>a[o]})}}return e.default=a,Object.freeze(e)}const s=_(m);function h(a,e){return s.Util.extend(e,a.geocodingQueryParams)}function g(a,e){return s.Util.extend(e,a.reverseQueryParams)}const A=/[&<>"'`]/g,W=/[&<>"'`]/,I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};function z(a){return I[a]}function q(a){return a==null?"":a?(a=""+a,W.test(a)?a.replace(A,z):a):a+""}function d(a,e){const o={Accept:"application/json"},t=new URL(a);return Object.entries(e).forEach(([n,i])=>{(Array.isArray(i)?i:[i]).forEach(r=>{t.searchParams.append(n,r)})}),fetch(t.toString(),{headers:o}).then(n=>n.json())}function H(a,e){return a.replace(/\{ *([\w_]+) *\}/g,(o,t)=>{let n=e[t];return n===void 0?n="":typeof n=="function"&&(n=n(e)),q(n)})}class w{constructor(e){p(this,"options",{serviceUrl:"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",apiKey:""});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{token:this.options.apiKey,SingleLine:e,outFields:"Addr_Type",forStorage:!1,maxLocations:10,f:"json"}),t=await d(this.options.serviceUrl+"/findAddressCandidates",o),n=[];if(t.candidates&&t.candidates.length)for(let i=0;i<=t.candidates.length-1;i++){const r=t.candidates[i],l=s.latLng(r.location.y,r.location.x),c=s.latLngBounds(s.latLng(r.extent.ymax,r.extent.xmax),s.latLng(r.extent.ymin,r.extent.xmin));n[i]={name:r.address,bbox:c,center:l}}return n}suggest(e){return this.geocode(e)}async reverse(e,o){const t=g(this.options,{location:e.lng+","+e.lat,distance:100,f:"json"}),n=await d(this.options.serviceUrl+"/reverseGeocode",t),i=[];if(n&&!n.error){const r=s.latLng(n.location.y,n.location.x),l=s.latLngBounds(r,r);i.push({name:n.address.Match_addr,center:r,bbox:l})}return i}}function J(a){return new w(a)}class U{constructor(e){p(this,"options",{serviceUrl:"https://dev.virtualearth.net/REST/v1/Locations/"});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{query:e,key:this.options.apiKey}),t=await d(this.options.serviceUrl,o),n=[];if(t.resourceSets.length>0)for(let i=t.resourceSets[0].resources.length-1;i>=0;i--){const r=t.resourceSets[0].resources[i],l=r.bbox;n[i]={name:r.name,bbox:s.latLngBounds([l[0],l[1]],[l[2],l[3]]),center:s.latLng(r.point.coordinates)}}return n}async reverse(e,o){const t=g(this.options,{key:this.options.apiKey}),n=await d(this.options.serviceUrl+e.lat+","+e.lng,t),i=[];for(let r=n.resourceSets[0].resources.length-1;r>=0;r--){const l=n.resourceSets[0].resources[r],c=l.bbox;i[r]={name:l.name,bbox:s.latLngBounds([c[0],c[1]],[c[2],c[3]]),center:s.latLng(l.point.coordinates)}}return i}}function V(a){return new U(a)}class C{constructor(e){p(this,"options",{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json"});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{key:this.options.apiKey,address:e}),t=await d(this.options.serviceUrl,o),n=[];if(t.results&&t.results.length)for(let i=0;i<=t.results.length-1;i++){const r=t.results[i],l=s.latLng(r.geometry.location),c=s.latLngBounds(s.latLng(r.geometry.viewport.northeast),s.latLng(r.geometry.viewport.southwest));n[i]={name:r.formatted_address,bbox:c,center:l,properties:r.address_components}}return n}async reverse(e,o){const t=g(this.options,{key:this.options.apiKey,latlng:e.lat+","+e.lng}),n=await d(this.options.serviceUrl,t),i=[];if(n.results&&n.results.length)for(let r=0;r<=n.results.length-1;r++){const l=n.results[r],c=s.latLng(l.geometry.location),f=s.latLngBounds(s.latLng(l.geometry.viewport.northeast),s.latLng(l.geometry.viewport.southwest));i[r]={name:l.formatted_address,bbox:f,center:c,properties:l.address_components}}return i}}function $(a){return new C(a)}class D{constructor(e){p(this,"options",{serviceUrl:"https://geocoder.api.here.com/6.2/",app_id:"",app_code:"",apiKey:"",maxResults:5});if(s.Util.setOptions(this,e),e!=null&&e.apiKey)throw Error("apiKey is not supported, use app_id/app_code instead!")}geocode(e){const o=h(this.options,{searchtext:e,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1,maxresults:this.options.maxResults});return this.getJSON(this.options.serviceUrl+"geocode.json",o)}reverse(e,o){let t=e.lat+","+e.lng;this.options.reverseGeocodeProxRadius&&(t+=","+this.options.reverseGeocodeProxRadius);const n=g(this.options,{prox:t,mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1,maxresults:this.options.maxResults});return this.getJSON(this.options.serviceUrl+"reversegeocode.json",n)}async getJSON(e,o){const t=await d(e,o),n=[];if(t.response.view&&t.response.view.length)for(let i=0;i<=t.response.view[0].result.length-1;i++){const r=t.response.view[0].result[i].location,l=s.latLng(r.displayPosition.latitude,r.displayPosition.longitude),c=s.latLngBounds(s.latLng(r.mapView.topLeft.latitude,r.mapView.topLeft.longitude),s.latLng(r.mapView.bottomRight.latitude,r.mapView.bottomRight.longitude));n[i]={name:r.address.label,properties:r.address,bbox:c,center:l}}return n}}class E{constructor(e){p(this,"options",{serviceUrl:"https://geocode.search.hereapi.com/v1",apiKey:"",app_id:"",app_code:"",maxResults:10});s.Util.setOptions(this,e)}geocode(e){const o=h(this.options,{q:e,apiKey:this.options.apiKey,limit:this.options.maxResults});if(!o.at&&!o.in)throw Error("at / in parameters not found. Please define coordinates (at=latitude,longitude) or other (in) in your geocodingQueryParams.");return this.getJSON(this.options.serviceUrl+"/discover",o)}reverse(e,o){const t=g(this.options,{at:e.lat+","+e.lng,limit:this.options.reverseGeocodeProxRadius,apiKey:this.options.apiKey});return this.getJSON(this.options.serviceUrl+"/revgeocode",t)}async getJSON(e,o){const t=await d(e,o),n=[];if(t.items&&t.items.length)for(let i=0;i<=t.items.length-1;i++){const r=t.items[i],l=s.latLng(r.position.lat,r.position.lng);let c;r.mapView?c=s.latLngBounds(s.latLng(r.mapView.south,r.mapView.west),s.latLng(r.mapView.north,r.mapView.east)):c=s.latLngBounds(s.latLng(r.position.lat,r.position.lng),s.latLng(r.position.lat,r.position.lng)),n[i]={name:r.address.label,properties:r.address,bbox:c,center:l}}return n}}function F(a){return a!=null&&a.apiKey?new E(a):new D(a)}function R(a){let e;if(e=a.match(/^([NS])\s*(\d{1,3}(?:\.\d*)?)\W*([EW])\s*(\d{1,3}(?:\.\d*)?)$/))return s.latLng((/N/i.test(e[1])?1:-1)*+e[2],(/E/i.test(e[3])?1:-1)*+e[4]);if(e=a.match(/^(\d{1,3}(?:\.\d*)?)\s*([NS])\W*(\d{1,3}(?:\.\d*)?)\s*([EW])$/))return s.latLng((/N/i.test(e[2])?1:-1)*+e[1],(/E/i.test(e[4])?1:-1)*+e[3]);if(e=a.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?$/))return s.latLng((/N/i.test(e[1])?1:-1)*(+e[2]+ +e[3]/60),(/E/i.test(e[4])?1:-1)*(+e[5]+ +e[6]/60));if(e=a.match(/^(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([EW])$/))return s.latLng((/N/i.test(e[3])?1:-1)*(+e[1]+ +e[2]/60),(/E/i.test(e[6])?1:-1)*(+e[4]+ +e[5]/60));if(e=a.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?$/))return s.latLng((/N/i.test(e[1])?1:-1)*(+e[2]+ +e[3]/60+ +e[4]/3600),(/E/i.test(e[5])?1:-1)*(+e[6]+ +e[7]/60+ +e[8]/3600));if(e=a.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\s*([EW])$/))return s.latLng((/N/i.test(e[4])?1:-1)*(+e[1]+ +e[2]/60+ +e[3]/3600),(/E/i.test(e[8])?1:-1)*(+e[5]+ +e[6]/60+ +e[7]/3600));if(e=a.match(/^\s*([+-]?\d+(?:\.\d*)?)\s*[\s,]\s*([+-]?\d+(?:\.\d*)?)\s*$/))return s.latLng(+e[1],+e[2])}class k{constructor(e){p(this,"options",{next:void 0,sizeInMeters:1e4});s.Util.setOptions(this,e)}async geocode(e){const o=R(e);return o?[{name:e,center:o,bbox:o.toBounds(this.options.sizeInMeters)}]:this.options.next?this.options.next.geocode(e):[]}}function Q(a){return new k(a)}class S{constructor(e){p(this,"options",{serviceUrl:"https://api.mapbox.com/geocoding/v5/mapbox.places/"});s.Util.setOptions(this,e)}_getProperties(e){const o={text:e.text,address:e.address};for(let t=0;t<(e.context||[]).length;t++){const n=e.context[t].id.split(".")[0];o[n]=e.context[t].text,e.context[t].short_code&&(o.countryShortCode=e.context[t].short_code)}return o}async geocode(e){const o=this.options.serviceUrl+encodeURIComponent(e)+".json",t=h(this.options,{access_token:this.options.apiKey});t.proximity!==void 0&&t.proximity.lat!==void 0&&t.proximity.lng!==void 0&&(t.proximity=t.proximity.lng+","+t.proximity.lat);const n=await d(o,t);return this._parseResults(n)}suggest(e){return this.geocode(e)}async reverse(e,o){const t=this.options.serviceUrl+e.lng+","+e.lat+".json",n=g(this.options,{access_token:this.options.apiKey}),i=await d(t,n);return this._parseResults(i)}_parseResults(e){var t;if(!((t=e.features)!=null&&t.length))return[];const o=[];for(let n=0;n<=e.features.length-1;n++){const i=e.features[n],r=s.latLng(i.center.reverse());let l;i.bbox?l=s.latLngBounds(s.latLng(i.bbox.slice(0,2).reverse()),s.latLng(i.bbox.slice(2,4).reverse())):l=s.latLngBounds(r,r),o[n]={name:i.place_name,bbox:l,center:r,properties:this._getProperties(i)}}return o}}function X(a){return new S(a)}class B{constructor(e){p(this,"options",{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"});s.Util.setOptions(this,e),this.options.apiKey=decodeURIComponent(this.options.apiKey)}_formatName(...e){return e.filter(o=>!!o).join(", ")}async geocode(e){const o=h(this.options,{key:this.options.apiKey,location:e,limit:5,outFormat:"json"}),t=await d(this.options.serviceUrl+"/address",o);return this._parseResults(t)}async reverse(e,o){const t=g(this.options,{key:this.options.apiKey,location:e.lat+","+e.lng,outputFormat:"json"}),n=await d(this.options.serviceUrl+"/reverse",t);return this._parseResults(n)}_parseResults(e){const o=[];if(e.results&&e.results[0].locations)for(let t=e.results[0].locations.length-1;t>=0;t--){const n=e.results[0].locations[t],i=s.latLng(n.latLng);o[t]={name:this._formatName(n.street,n.adminArea4,n.adminArea3,n.adminArea1),bbox:s.latLngBounds(i,i),center:i}}return o}}function Y(a){return new B(a)}class O{constructor(e){p(this,"options",{userId:"",apiKey:"",serviceUrl:"https://neutrinoapi.com/"});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{apiKey:this.options.apiKey,userId:this.options.userId,address:e.split(/\s+/).join(".")}),t=await d(this.options.serviceUrl+"geocode-address",o),n=[];if(t.locations){t.geometry=t.locations[0];const i=s.latLng(t.geometry.latitude,t.geometry.longitude),r=s.latLngBounds(i,i);n[0]={name:t.geometry.address,bbox:r,center:i}}return n}suggest(e){return this.geocode(e)}async reverse(e,o){const t=g(this.options,{apiKey:this.options.apiKey,userId:this.options.userId,latitude:e.lat,longitude:e.lng}),n=await d(this.options.serviceUrl+"geocode-reverse",t),i=[];if(n.status.status==200&&n.found){const r=s.latLng(e.lat,e.lng),l=s.latLngBounds(r,r);i[0]={name:n.address,bbox:l,center:r}}return i}}function Z(a){return new O(a)}class y{constructor(e){p(this,"options",{serviceUrl:"https://nominatim.openstreetmap.org/",htmlTemplate:function(e){const o=e.address;let t;const n=[];return(o.road||o.building)&&n.push("{building} {road} {house_number}"),(o.city||o.town||o.village||o.hamlet)&&(t=n.length>0?"leaflet-control-geocoder-address-detail":"",n.push('<span class="'+t+'">{postcode} {city} {town} {village} {hamlet}</span>')),(o.state||o.country)&&(t=n.length>0?"leaflet-control-geocoder-address-context":"",n.push('<span class="'+t+'">{state} {country}</span>')),H(n.join("<br/>"),o)}});s.Util.setOptions(this,e||{})}async geocode(e){const o=h(this.options,{q:e,limit:5,format:"json",addressdetails:1}),t=await d(this.options.serviceUrl+"search",o),n=[];for(let i=t.length-1;i>=0;i--){const r=t[i].boundingbox;n[i]={icon:t[i].icon,name:t[i].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(t[i]):void 0,bbox:s.latLngBounds([+r[0],+r[2]],[+r[1],+r[3]]),center:s.latLng(+t[i].lat,+t[i].lon),properties:t[i]}}return n}async reverse(e,o){const t=g(this.options,{lat:e.lat,lon:e.lng,zoom:Math.round(Math.log(o/256)/Math.log(2)),addressdetails:1,format:"json"}),n=await d(this.options.serviceUrl+"reverse",t),i=[];if(n&&n.lat&&n.lon){const r=s.latLng(+n.lat,+n.lon),l=s.latLngBounds(r,r);i.push({name:n.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(n):void 0,center:r,bbox:l,properties:n})}return i}}function ee(a){return new y(a)}class T{constructor(e){p(this,"options",{});s.Util.setOptions(this,e)}async geocode(e){try{const o=this.options.OpenLocationCode.decode(e);return[{name:e,center:s.latLng(o.latitudeCenter,o.longitudeCenter),bbox:s.latLngBounds(s.latLng(o.latitudeLo,o.longitudeLo),s.latLng(o.latitudeHi,o.longitudeHi))}]}catch(o){return console.warn(o),[]}}async reverse(e,o){try{return[{name:this.options.OpenLocationCode.encode(e.lat,e.lng,this.options.codeLength),center:s.latLng(e.lat,e.lng),bbox:s.latLngBounds(s.latLng(e.lat,e.lng),s.latLng(e.lat,e.lng))}]}catch(t){return console.warn(t),[]}}}function te(a){return new T(a)}class j{constructor(e){p(this,"options",{serviceUrl:"https://api.opencagedata.com/geocode/v1/json"});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{key:this.options.apiKey,q:e}),t=await d(this.options.serviceUrl,o);return this._parseResults(t)}suggest(e){return this.geocode(e)}async reverse(e,o){const t=g(this.options,{key:this.options.apiKey,q:[e.lat,e.lng].join(",")}),n=await d(this.options.serviceUrl,t);return this._parseResults(n)}_parseResults(e){const o=[];if(e.results&&e.results.length)for(let t=0;t<e.results.length;t++){const n=e.results[t],i=s.latLng(n.geometry);let r;n.annotations&&n.annotations.bounds?r=s.latLngBounds(s.latLng(n.annotations.bounds.northeast),s.latLng(n.annotations.bounds.southwest)):r=s.latLngBounds(i,i),o.push({name:n.formatted,bbox:r,center:i})}return o}}function se(a){return new j(a)}class v{constructor(e){p(this,"options",{serviceUrl:"https://api.geocode.earth/v1"});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{api_key:this.options.apiKey,text:e}),t=await d(this.options.serviceUrl+"/search",o);return this._parseResults(t,"bbox")}async suggest(e){const o=h(this.options,{api_key:this.options.apiKey,text:e}),t=await d(this.options.serviceUrl+"/autocomplete",o);return this._parseResults(t,"bbox")}async reverse(e,o){const t=g(this.options,{api_key:this.options.apiKey,"point.lat":e.lat,"point.lon":e.lng}),n=await d(this.options.serviceUrl+"/reverse",t);return this._parseResults(n,"bounds")}_parseResults(e,o){const t=[];return s.geoJSON(e,{pointToLayer(n,i){return s.circleMarker(i)},onEachFeature(n,i){const r={};let l,c;i.getBounds?(l=i.getBounds(),c=l.getCenter()):i.feature.bbox?(c=i.getLatLng(),l=s.latLngBounds(s.GeoJSON.coordsToLatLng(i.feature.bbox.slice(0,2)),s.GeoJSON.coordsToLatLng(i.feature.bbox.slice(2,4)))):(c=i.getLatLng(),l=s.latLngBounds(c,c)),r.name=i.feature.properties.label,r.center=c,r[o]=l,r.properties=i.feature.properties,t.push(r)}}),t}}function L(a){return new v(a)}const oe=v,ne=L,ie=v,re=L;class K extends v{constructor(e){super(s.Util.extend({serviceUrl:"https://api.openrouteservice.org/geocode"},e))}}function ae(a){return new K(a)}class N{constructor(e){p(this,"options",{serviceUrl:"https://photon.komoot.io/api/",reverseUrl:"https://photon.komoot.io/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]});s.Util.setOptions(this,e)}async geocode(e){const o=h(this.options,{q:e}),t=await d(this.options.serviceUrl,o);return this._parseResults(t)}suggest(e){return this.geocode(e)}async reverse(e,o){const t=g(this.options,{lat:e.lat,lon:e.lng}),n=await d(this.options.reverseUrl,t);return this._parseResults(n)}_parseResults(e){var t;const o=[];if(e&&e.features)for(let n=0;n<e.features.length;n++){const i=e.features[n],r=i.geometry.coordinates,l=s.latLng(r[1],r[0]),c=(t=i.properties)==null?void 0:t.extent,f=c?s.latLngBounds([c[1],c[0]],[c[3],c[2]]):s.latLngBounds(l,l);o.push({name:this._decodeFeatureName(i),html:this.options.htmlTemplate?this.options.htmlTemplate(i):void 0,center:l,bbox:f,properties:i.properties})}return o}_decodeFeatureName(e){return(this.options.nameProperties||[]).map(o=>{var t;return(t=e.properties)==null?void 0:t[o]}).filter(o=>!!o).join(", ")}}function le(a){return new N(a)}class M{constructor(e){p(this,"options",{serviceUrl:"https://api.what3words.com/v2/"});s.Util.setOptions(this,e)}async geocode(e){const o=await d(this.options.serviceUrl+"forward",h(this.options,{key:this.options.apiKey,addr:e.split(/\s+/).join(".")})),t=[];if(o.geometry){const n=s.latLng(o.geometry.lat,o.geometry.lng),i=s.latLngBounds(n,n);t[0]={name:o.words,bbox:i,center:n}}return t}suggest(e){return this.geocode(e)}async reverse(e,o){const t=await d(this.options.serviceUrl+"reverse",g(this.options,{key:this.options.apiKey,coords:[e.lat,e.lng].join(",")})),n=[];if(t.status.status==200){const i=s.latLng(t.geometry.lat,t.geometry.lng),r=s.latLngBounds(i,i);n[0]={name:t.words,bbox:r,center:i}}return n}}function ce(a){return new M(a)}const P=Object.freeze(Object.defineProperty({__proto__:null,ArcGis:w,Bing:U,GeocodeEarth:oe,Google:C,HERE:D,HEREv2:E,LatLng:k,MapQuest:B,Mapbox:S,Mapzen:ie,Neutrino:O,Nominatim:y,OpenCage:j,OpenLocationCode:T,Openrouteservice:K,Pelias:v,Photon:N,What3Words:M,arcgis:J,bing:V,geocodeEarth:ne,geocodingParams:h,google:$,here:F,latLng:Q,mapQuest:Y,mapbox:X,mapzen:re,neutrino:Z,nominatim:ee,openLocationCode:te,opencage:se,openrouteservice:ae,parseLatLng:R,pelias:L,photon:le,reverseParams:g,what3words:ce},Symbol.toStringTag,{value:"Module"}));class x{constructor(...e){}}s.Util.extend(x.prototype,s.Control.prototype),s.Util.extend(x.prototype,s.Evented.prototype);class b extends x{constructor(o){super(o);p(this,"options",{showUniqueResult:!0,showResultIcons:!1,collapsed:!0,expand:"touch",position:"topright",placeholder:"Search...",errorMessage:"Nothing found.",iconLabel:"Initiate a new search",query:"",queryMinLength:1,suggestMinLength:3,suggestTimeout:250,defaultMarkGeocode:!0});p(this,"_alts");p(this,"_container");p(this,"_errorElement");p(this,"_geocodeMarker");p(this,"_input");p(this,"_lastGeocode");p(this,"_map");p(this,"_preventBlurCollapse");p(this,"_requestCount",0);p(this,"_results");p(this,"_selection");p(this,"_suggestTimeout");s.Util.setOptions(this,o),this.options.geocoder||(this.options.geocoder=new y)}addThrobberClass(){s.DomUtil.addClass(this._container,"leaflet-control-geocoder-throbber")}removeThrobberClass(){s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-throbber")}onAdd(o){var c;const t="leaflet-control-geocoder",n=s.DomUtil.create("div",t+" leaflet-bar"),i=s.DomUtil.create("button",t+"-icon",n),r=s.DomUtil.create("div",t+"-form",n);this._map=o,this._container=n,i.innerHTML=" ",i.type="button",i.setAttribute("aria-label",this.options.iconLabel);const l=this._input=s.DomUtil.create("input","",r);return l.type="search",l.value=this.options.query,l.placeholder=this.options.placeholder,s.DomEvent.disableClickPropagation(l),this._errorElement=s.DomUtil.create("div",t+"-form-no-error",n),this._errorElement.innerHTML=this.options.errorMessage,this._alts=s.DomUtil.create("ul",t+"-alternatives leaflet-control-geocoder-alternatives-minimized",n),s.DomEvent.disableClickPropagation(this._alts),s.DomEvent.addListener(l,"keydown",this._keydown,this),(c=this.options.geocoder)!=null&&c.suggest&&s.DomEvent.addListener(l,"input",this._change,this),s.DomEvent.addListener(l,"blur",()=>{this.options.collapsed&&!this._preventBlurCollapse&&this._collapse(),this._preventBlurCollapse=!1}),this.options.collapsed?this.options.expand==="click"?s.DomEvent.addListener(n,"click",f=>{f.button===0&&f.detail!==2&&this._toggle()}):this.options.expand==="touch"?s.DomEvent.addListener(n,s.Browser.touch?"touchstart mousedown":"mousedown",f=>{this._toggle(),f.preventDefault(),f.stopPropagation()},this):(s.DomEvent.addListener(n,"mouseover",this._expand,this),s.DomEvent.addListener(n,"mouseout",this._collapse,this),this._map.on("movestart",this._collapse,this)):(this._expand(),s.Browser.touch?s.DomEvent.addListener(n,"touchstart",()=>this._geocode()):s.DomEvent.addListener(n,"click",()=>this._geocode())),this.options.defaultMarkGeocode&&this.on("markgeocode",this.markGeocode,this),this.on("startgeocode",this.addThrobberClass,this),this.on("finishgeocode",this.removeThrobberClass,this),this.on("startsuggest",this.addThrobberClass,this),this.on("finishsuggest",this.removeThrobberClass,this),s.DomEvent.disableClickPropagation(n),n}setQuery(o){return this._input.value=o,this}_geocodeResult(o,t){if(!t&&this.options.showUniqueResult&&o.length===1)this._geocodeResultSelected(o[0]);else if(o.length>0){this._alts.innerHTML="",this._results=o,s.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),s.DomUtil.addClass(this._container,"leaflet-control-geocoder-options-open");for(let n=0;n<o.length;n++)this._alts.appendChild(this._createAlt(o[n],n))}else s.DomUtil.addClass(this._container,"leaflet-control-geocoder-options-error"),s.DomUtil.addClass(this._errorElement,"leaflet-control-geocoder-error")}markGeocode(o){const t=o.geocode;return this._map.fitBounds(t.bbox),this._geocodeMarker&&this._map.removeLayer(this._geocodeMarker),this._geocodeMarker=new s.Marker(t.center).bindPopup(t.html||t.name).addTo(this._map).openPopup(),this}async _geocode(o=!1){const t=this._input.value;if(!o&&t.length<this.options.queryMinLength)return;const n=++this._requestCount;this._lastGeocode=t,o||this._clearResults();const i={input:t};this.fire(o?"startsuggest":"startgeocode",i);const r=o?await this.options.geocoder.suggest(t):await this.options.geocoder.geocode(t);if(n===this._requestCount){const l={input:t,results:r};this.fire(o?"finishsuggest":"finishgeocode",l),this._geocodeResult(r,o)}}_geocodeResultSelected(o){const t={geocode:o};this.fire("markgeocode",t)}_toggle(){s.DomUtil.hasClass(this._container,"leaflet-control-geocoder-expanded")?this._collapse():this._expand()}_expand(){s.DomUtil.addClass(this._container,"leaflet-control-geocoder-expanded"),this._input.select(),this.fire("expand")}_collapse(){s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-expanded"),s.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),s.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-open"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-error"),this._input.blur(),this.fire("collapse")}_clearResults(){s.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),this._selection=null,s.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-open"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-error")}_createAlt(o,t){const n=s.DomUtil.create("li",""),i=s.DomUtil.create("a","",n),r=this.options.showResultIcons&&o.icon?s.DomUtil.create("img","",i):null,l=o.html?void 0:document.createTextNode(o.name),c=f=>{this._preventBlurCollapse=!0,s.DomEvent.stop(f),this._geocodeResultSelected(o),s.DomEvent.on(n,"click touchend",()=>{this.options.collapsed?this._collapse():this._clearResults()})};return r&&(r.src=o.icon),n.setAttribute("data-result-index",String(t)),o.html?i.innerHTML=i.innerHTML+o.html:l&&i.appendChild(l),s.DomEvent.addListener(n,"mousedown touchstart",c,this),n}_keydown(o){const t=n=>{this._selection&&(s.DomUtil.removeClass(this._selection,"leaflet-control-geocoder-selected"),this._selection=this._selection[n>0?"nextSibling":"previousSibling"]),this._selection||(this._selection=this._alts[n>0?"firstChild":"lastChild"]),this._selection&&s.DomUtil.addClass(this._selection,"leaflet-control-geocoder-selected")};switch(o.keyCode){case 27:this.options.collapsed?this._collapse():this._clearResults();break;case 38:t(-1);break;case 40:t(1);break;case 13:if(this._selection){const n=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[n]),this._clearResults()}else this._geocode();break;default:return}s.DomEvent.preventDefault(o)}_change(){const o=this._input.value;o!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),o.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(()=>this._geocode(!0),this.options.suggestTimeout):this._clearResults())}}function G(a){return new b(a)}/* @preserve | ||
(function(u,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("leaflet")):typeof define=="function"&&define.amd?define(["exports","leaflet"],m):(u=typeof globalThis<"u"?globalThis:u||self,m(u["leaflet-control-geocoder"]={},u.L))})(this,function(u,m){"use strict";var ut=Object.defineProperty;var ht=(u,m,v)=>m in u?ut(u,m,{enumerable:!0,configurable:!0,writable:!0,value:v}):u[m]=v;var p=(u,m,v)=>ht(u,typeof m!="symbol"?m+"":m,v);function v(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,e.get?e:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const s=v(m);function h(a,t){return s.Util.extend(t,a.geocodingQueryParams)}function g(a,t){return s.Util.extend(t,a.reverseQueryParams)}const W=/[&<>"'`]/g,z=/[&<>"'`]/,I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};function q(a){return I[a]}function H(a){return a==null?"":a?(a=""+a,z.test(a)?a.replace(W,q):a):a+""}function d(a,t){const n={Accept:"application/json"},e=new URL(a);return Object.entries(t).forEach(([o,i])=>{(Array.isArray(i)?i:[i]).forEach(r=>{e.searchParams.append(o,r)})}),fetch(e.toString(),{headers:n}).then(o=>o.json())}function J(a,t){return a.replace(/\{ *([\w_]+) *\}/g,(n,e)=>{let o=t[e];return o===void 0?o="":typeof o=="function"&&(o=o(t)),H(o)})}class x{constructor(t){p(this,"options",{serviceUrl:"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",apiKey:""});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{token:this.options.apiKey,SingleLine:t,outFields:"Addr_Type",forStorage:!1,maxLocations:10,f:"json"}),e=await d(this.options.serviceUrl+"/findAddressCandidates",n),o=[];if(e.candidates&&e.candidates.length)for(let i=0;i<=e.candidates.length-1;i++){const r=e.candidates[i],l=s.latLng(r.location.y,r.location.x),c=s.latLngBounds(s.latLng(r.extent.ymax,r.extent.xmax),s.latLng(r.extent.ymin,r.extent.xmin));o[i]={name:r.address,bbox:c,center:l}}return o}suggest(t){return this.geocode(t)}async reverse(t,n){const e=g(this.options,{location:t.lng+","+t.lat,distance:100,f:"json"}),o=await d(this.options.serviceUrl+"/reverseGeocode",e),i=[];if(o&&!o.error){const r=s.latLng(o.location.y,o.location.x),l=s.latLngBounds(r,r);i.push({name:o.address.Match_addr,center:r,bbox:l})}return i}}function V(a){return new x(a)}class U{constructor(t){p(this,"options",{serviceUrl:"https://dev.virtualearth.net/REST/v1/Locations/"});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{query:t,key:this.options.apiKey}),e=await d(this.options.serviceUrl,n),o=[];if(e.resourceSets.length>0)for(let i=e.resourceSets[0].resources.length-1;i>=0;i--){const r=e.resourceSets[0].resources[i],l=r.bbox;o[i]={name:r.name,bbox:s.latLngBounds([l[0],l[1]],[l[2],l[3]]),center:s.latLng(r.point.coordinates)}}return o}async reverse(t,n){const e=g(this.options,{key:this.options.apiKey}),o=await d(this.options.serviceUrl+t.lat+","+t.lng,e),i=[];for(let r=o.resourceSets[0].resources.length-1;r>=0;r--){const l=o.resourceSets[0].resources[r],c=l.bbox;i[r]={name:l.name,bbox:s.latLngBounds([c[0],c[1]],[c[2],c[3]]),center:s.latLng(l.point.coordinates)}}return i}}function $(a){return new U(a)}class C{constructor(t){p(this,"options",{apiKey:"",serviceUrl:"https://atlas.microsoft.com/search"});if(s.Util.setOptions(this,t),!this.options.apiKey)throw new Error("Azure Maps Geocoder requires an API key.")}async geocode(t){const n={"api-version":"1.0",query:t,"subscription-key":this.options.apiKey},e=this.options.serviceUrl+"/address/json",o=await d(e,n),i=[];if(o.results&&o.results.length>0)for(const r of o.results)i.push({name:r.address.freeformAddress,bbox:s.latLngBounds([r.viewport.topLeftPoint.lat,r.viewport.topLeftPoint.lon],[r.viewport.btmRightPoint.lat,r.viewport.btmRightPoint.lon]),center:s.latLng(r.position.lat,r.position.lon)});return i}async reverse(t,n){const e={"api-version":"1.0",query:t.lat+","+t.lng,"subscription-key":this.options.apiKey},o=this.options.serviceUrl+"/address/reverse/json",i=await d(o,e),r=[];if(i.addresses&&i.addresses.length>0)for(const l of i.addresses)r.push({name:l.address.freeformAddress,bbox:s.latLngBounds([l.viewport.topLeftPoint.lat,l.viewport.topLeftPoint.lon],[l.viewport.btmRightPoint.lat,l.viewport.btmRightPoint.lon]),center:s.latLng(t.lat,t.lng)});return r}}function F(a){return new C(a)}class R{constructor(t){p(this,"options",{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json"});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{key:this.options.apiKey,address:t}),e=await d(this.options.serviceUrl,n),o=[];if(e.results&&e.results.length)for(let i=0;i<=e.results.length-1;i++){const r=e.results[i],l=s.latLng(r.geometry.location),c=s.latLngBounds(s.latLng(r.geometry.viewport.northeast),s.latLng(r.geometry.viewport.southwest));o[i]={name:r.formatted_address,bbox:c,center:l,properties:r.address_components}}return o}async reverse(t,n){const e=g(this.options,{key:this.options.apiKey,latlng:t.lat+","+t.lng}),o=await d(this.options.serviceUrl,e),i=[];if(o.results&&o.results.length)for(let r=0;r<=o.results.length-1;r++){const l=o.results[r],c=s.latLng(l.geometry.location),f=s.latLngBounds(s.latLng(l.geometry.viewport.northeast),s.latLng(l.geometry.viewport.southwest));i[r]={name:l.formatted_address,bbox:f,center:c,properties:l.address_components}}return i}}function Q(a){return new R(a)}class E{constructor(t){p(this,"options",{serviceUrl:"https://geocoder.api.here.com/6.2/",app_id:"",app_code:"",apiKey:"",maxResults:5});if(s.Util.setOptions(this,t),t!=null&&t.apiKey)throw Error("apiKey is not supported, use app_id/app_code instead!")}geocode(t){const n=h(this.options,{searchtext:t,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1,maxresults:this.options.maxResults});return this.getJSON(this.options.serviceUrl+"geocode.json",n)}reverse(t,n){let e=t.lat+","+t.lng;this.options.reverseGeocodeProxRadius&&(e+=","+this.options.reverseGeocodeProxRadius);const o=g(this.options,{prox:e,mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1,maxresults:this.options.maxResults});return this.getJSON(this.options.serviceUrl+"reversegeocode.json",o)}async getJSON(t,n){const e=await d(t,n),o=[];if(e.response.view&&e.response.view.length)for(let i=0;i<=e.response.view[0].result.length-1;i++){const r=e.response.view[0].result[i].location,l=s.latLng(r.displayPosition.latitude,r.displayPosition.longitude),c=s.latLngBounds(s.latLng(r.mapView.topLeft.latitude,r.mapView.topLeft.longitude),s.latLng(r.mapView.bottomRight.latitude,r.mapView.bottomRight.longitude));o[i]={name:r.address.label,properties:r.address,bbox:c,center:l}}return o}}class k{constructor(t){p(this,"options",{serviceUrl:"https://geocode.search.hereapi.com/v1",apiKey:"",app_id:"",app_code:"",maxResults:10});s.Util.setOptions(this,t)}geocode(t){const n=h(this.options,{q:t,apiKey:this.options.apiKey,limit:this.options.maxResults});if(!n.at&&!n.in)throw Error("at / in parameters not found. Please define coordinates (at=latitude,longitude) or other (in) in your geocodingQueryParams.");return this.getJSON(this.options.serviceUrl+"/discover",n)}reverse(t,n){const e=g(this.options,{at:t.lat+","+t.lng,limit:this.options.reverseGeocodeProxRadius,apiKey:this.options.apiKey});return this.getJSON(this.options.serviceUrl+"/revgeocode",e)}async getJSON(t,n){const e=await d(t,n),o=[];if(e.items&&e.items.length)for(let i=0;i<=e.items.length-1;i++){const r=e.items[i],l=s.latLng(r.position.lat,r.position.lng);let c;r.mapView?c=s.latLngBounds(s.latLng(r.mapView.south,r.mapView.west),s.latLng(r.mapView.north,r.mapView.east)):c=s.latLngBounds(s.latLng(r.position.lat,r.position.lng),s.latLng(r.position.lat,r.position.lng)),o[i]={name:r.address.label,properties:r.address,bbox:c,center:l}}return o}}function X(a){return a!=null&&a.apiKey?new k(a):new E(a)}function D(a){let t;if(t=a.match(/^([NS])\s*(\d{1,3}(?:\.\d*)?)\W*([EW])\s*(\d{1,3}(?:\.\d*)?)$/))return s.latLng((/N/i.test(t[1])?1:-1)*+t[2],(/E/i.test(t[3])?1:-1)*+t[4]);if(t=a.match(/^(\d{1,3}(?:\.\d*)?)\s*([NS])\W*(\d{1,3}(?:\.\d*)?)\s*([EW])$/))return s.latLng((/N/i.test(t[2])?1:-1)*+t[1],(/E/i.test(t[4])?1:-1)*+t[3]);if(t=a.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?$/))return s.latLng((/N/i.test(t[1])?1:-1)*(+t[2]+ +t[3]/60),(/E/i.test(t[4])?1:-1)*(+t[5]+ +t[6]/60));if(t=a.match(/^(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([EW])$/))return s.latLng((/N/i.test(t[3])?1:-1)*(+t[1]+ +t[2]/60),(/E/i.test(t[6])?1:-1)*(+t[4]+ +t[5]/60));if(t=a.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?$/))return s.latLng((/N/i.test(t[1])?1:-1)*(+t[2]+ +t[3]/60+ +t[4]/3600),(/E/i.test(t[5])?1:-1)*(+t[6]+ +t[7]/60+ +t[8]/3600));if(t=a.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\s*([EW])$/))return s.latLng((/N/i.test(t[4])?1:-1)*(+t[1]+ +t[2]/60+ +t[3]/3600),(/E/i.test(t[8])?1:-1)*(+t[5]+ +t[6]/60+ +t[7]/3600));if(t=a.match(/^\s*([+-]?\d+(?:\.\d*)?)\s*[\s,]\s*([+-]?\d+(?:\.\d*)?)\s*$/))return s.latLng(+t[1],+t[2])}class B{constructor(t){p(this,"options",{next:void 0,sizeInMeters:1e4});s.Util.setOptions(this,t)}async geocode(t){const n=D(t);return n?[{name:t,center:n,bbox:n.toBounds(this.options.sizeInMeters)}]:this.options.next?this.options.next.geocode(t):[]}}function Y(a){return new B(a)}class O{constructor(t){p(this,"options",{serviceUrl:"https://api.mapbox.com/geocoding/v5/mapbox.places/"});s.Util.setOptions(this,t)}_getProperties(t){const n={text:t.text,address:t.address};for(let e=0;e<(t.context||[]).length;e++){const o=t.context[e].id.split(".")[0];n[o]=t.context[e].text,t.context[e].short_code&&(n.countryShortCode=t.context[e].short_code)}return n}async geocode(t){const n=this.options.serviceUrl+encodeURIComponent(t)+".json",e=h(this.options,{access_token:this.options.apiKey});e.proximity!==void 0&&e.proximity.lat!==void 0&&e.proximity.lng!==void 0&&(e.proximity=e.proximity.lng+","+e.proximity.lat);const o=await d(n,e);return this._parseResults(o)}suggest(t){return this.geocode(t)}async reverse(t,n){const e=this.options.serviceUrl+t.lng+","+t.lat+".json",o=g(this.options,{access_token:this.options.apiKey}),i=await d(e,o);return this._parseResults(i)}_parseResults(t){var e;if(!((e=t.features)!=null&&e.length))return[];const n=[];for(let o=0;o<=t.features.length-1;o++){const i=t.features[o],r=s.latLng(i.center.reverse());let l;i.bbox?l=s.latLngBounds(s.latLng(i.bbox.slice(0,2).reverse()),s.latLng(i.bbox.slice(2,4).reverse())):l=s.latLngBounds(r,r),n[o]={name:i.place_name,bbox:l,center:r,properties:this._getProperties(i)}}return n}}function Z(a){return new O(a)}class S{constructor(t){p(this,"options",{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"});s.Util.setOptions(this,t),this.options.apiKey=decodeURIComponent(this.options.apiKey)}_formatName(...t){return t.filter(n=>!!n).join(", ")}async geocode(t){const n=h(this.options,{key:this.options.apiKey,location:t,limit:5,outFormat:"json"}),e=await d(this.options.serviceUrl+"/address",n);return this._parseResults(e)}async reverse(t,n){const e=g(this.options,{key:this.options.apiKey,location:t.lat+","+t.lng,outputFormat:"json"}),o=await d(this.options.serviceUrl+"/reverse",e);return this._parseResults(o)}_parseResults(t){const n=[];if(t.results&&t.results[0].locations)for(let e=t.results[0].locations.length-1;e>=0;e--){const o=t.results[0].locations[e],i=s.latLng(o.latLng);n[e]={name:this._formatName(o.street,o.adminArea4,o.adminArea3,o.adminArea1),bbox:s.latLngBounds(i,i),center:i}}return n}}function tt(a){return new S(a)}class K{constructor(t){p(this,"options",{userId:"",apiKey:"",serviceUrl:"https://neutrinoapi.com/"});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{apiKey:this.options.apiKey,userId:this.options.userId,address:t.split(/\s+/).join(".")}),e=await d(this.options.serviceUrl+"geocode-address",n),o=[];if(e.locations){e.geometry=e.locations[0];const i=s.latLng(e.geometry.latitude,e.geometry.longitude),r=s.latLngBounds(i,i);o[0]={name:e.geometry.address,bbox:r,center:i}}return o}suggest(t){return this.geocode(t)}async reverse(t,n){const e=g(this.options,{apiKey:this.options.apiKey,userId:this.options.userId,latitude:t.lat,longitude:t.lng}),o=await d(this.options.serviceUrl+"geocode-reverse",e),i=[];if(o.status.status==200&&o.found){const r=s.latLng(t.lat,t.lng),l=s.latLngBounds(r,r);i[0]={name:o.address,bbox:l,center:r}}return i}}function et(a){return new K(a)}class y{constructor(t){p(this,"options",{serviceUrl:"https://nominatim.openstreetmap.org/",htmlTemplate(t){const n=t.address;let e;const o=[];return(n.road||n.building)&&o.push("{building} {road} {house_number}"),(n.city||n.town||n.village||n.hamlet)&&(e=o.length>0?"leaflet-control-geocoder-address-detail":"",o.push('<span class="'+e+'">{postcode} {city} {town} {village} {hamlet}</span>')),(n.state||n.country)&&(e=o.length>0?"leaflet-control-geocoder-address-context":"",o.push('<span class="'+e+'">{state} {country}</span>')),J(o.join("<br/>"),n)}});s.Util.setOptions(this,t||{})}async geocode(t){const n=h(this.options,{q:t,limit:5,format:"json",addressdetails:1}),e=await d(this.options.serviceUrl+"search",n),o=[];for(let i=e.length-1;i>=0;i--){const r=e[i].boundingbox;o[i]={icon:e[i].icon,name:e[i].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e[i]):void 0,bbox:s.latLngBounds([+r[0],+r[2]],[+r[1],+r[3]]),center:s.latLng(+e[i].lat,+e[i].lon),properties:e[i]}}return o}async reverse(t,n){const e=g(this.options,{lat:t.lat,lon:t.lng,zoom:Math.round(Math.log(n/256)/Math.log(2)),addressdetails:1,format:"json"}),o=await d(this.options.serviceUrl+"reverse",e),i=[];if(o&&o.lat&&o.lon){const r=s.latLng(+o.lat,+o.lon),l=s.latLngBounds(r,r);i.push({name:o.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(o):void 0,center:r,bbox:l,properties:o})}return i}}function st(a){return new y(a)}class P{constructor(t){p(this,"options",{});s.Util.setOptions(this,t)}async geocode(t){try{const n=this.options.OpenLocationCode.decode(t);return[{name:t,center:s.latLng(n.latitudeCenter,n.longitudeCenter),bbox:s.latLngBounds(s.latLng(n.latitudeLo,n.longitudeLo),s.latLng(n.latitudeHi,n.longitudeHi))}]}catch(n){return console.warn(n),[]}}async reverse(t,n){try{return[{name:this.options.OpenLocationCode.encode(t.lat,t.lng,this.options.codeLength),center:s.latLng(t.lat,t.lng),bbox:s.latLngBounds(s.latLng(t.lat,t.lng),s.latLng(t.lat,t.lng))}]}catch(e){return console.warn(e),[]}}}function ot(a){return new P(a)}class T{constructor(t){p(this,"options",{serviceUrl:"https://api.opencagedata.com/geocode/v1/json"});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{key:this.options.apiKey,q:t}),e=await d(this.options.serviceUrl,n);return this._parseResults(e)}suggest(t){return this.geocode(t)}async reverse(t,n){const e=g(this.options,{key:this.options.apiKey,q:[t.lat,t.lng].join(",")}),o=await d(this.options.serviceUrl,e);return this._parseResults(o)}_parseResults(t){const n=[];if(t.results&&t.results.length)for(let e=0;e<t.results.length;e++){const o=t.results[e],i=s.latLng(o.geometry);let r;o.annotations&&o.annotations.bounds?r=s.latLngBounds(s.latLng(o.annotations.bounds.northeast),s.latLng(o.annotations.bounds.southwest)):r=s.latLngBounds(i,i),n.push({name:o.formatted,bbox:r,center:i})}return n}}function nt(a){return new T(a)}class _{constructor(t){p(this,"options",{serviceUrl:"https://api.geocode.earth/v1"});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{api_key:this.options.apiKey,text:t}),e=await d(this.options.serviceUrl+"/search",n);return this._parseResults(e,"bbox")}async suggest(t){const n=h(this.options,{api_key:this.options.apiKey,text:t}),e=await d(this.options.serviceUrl+"/autocomplete",n);return this._parseResults(e,"bbox")}async reverse(t,n){const e=g(this.options,{api_key:this.options.apiKey,"point.lat":t.lat,"point.lon":t.lng}),o=await d(this.options.serviceUrl+"/reverse",e);return this._parseResults(o,"bounds")}_parseResults(t,n){const e=[];return s.geoJSON(t,{pointToLayer(o,i){return s.circleMarker(i)},onEachFeature(o,i){const r={};let l,c;i.getBounds?(l=i.getBounds(),c=l.getCenter()):i.feature.bbox?(c=i.getLatLng(),l=s.latLngBounds(s.GeoJSON.coordsToLatLng(i.feature.bbox.slice(0,2)),s.GeoJSON.coordsToLatLng(i.feature.bbox.slice(2,4)))):(c=i.getLatLng(),l=s.latLngBounds(c,c)),r.name=i.feature.properties.label,r.center=c,r[n]=l,r.properties=i.feature.properties,e.push(r)}}),e}}function L(a){return new _(a)}const it=_,rt=L,at=_,lt=L;class j extends _{constructor(t){super(s.Util.extend({serviceUrl:"https://api.openrouteservice.org/geocode"},t))}}function ct(a){return new j(a)}class M{constructor(t){p(this,"options",{serviceUrl:"https://photon.komoot.io/api/",reverseUrl:"https://photon.komoot.io/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]});s.Util.setOptions(this,t)}async geocode(t){const n=h(this.options,{q:t}),e=await d(this.options.serviceUrl,n);return this._parseResults(e)}suggest(t){return this.geocode(t)}async reverse(t,n){const e=g(this.options,{lat:t.lat,lon:t.lng}),o=await d(this.options.reverseUrl,e);return this._parseResults(o)}_parseResults(t){var e;const n=[];if(t&&t.features)for(let o=0;o<t.features.length;o++){const i=t.features[o],r=i.geometry.coordinates,l=s.latLng(r[1],r[0]),c=(e=i.properties)==null?void 0:e.extent,f=c?s.latLngBounds([c[1],c[0]],[c[3],c[2]]):s.latLngBounds(l,l);n.push({name:this._decodeFeatureName(i),html:this.options.htmlTemplate?this.options.htmlTemplate(i):void 0,center:l,bbox:f,properties:i.properties})}return n}_decodeFeatureName(t){return(this.options.nameProperties||[]).map(n=>{var e;return(e=t.properties)==null?void 0:e[n]}).filter(n=>!!n).join(", ")}}function pt(a){return new M(a)}class N{constructor(t){p(this,"options",{serviceUrl:"https://api.what3words.com/v2/"});s.Util.setOptions(this,t)}async geocode(t){const n=await d(this.options.serviceUrl+"forward",h(this.options,{key:this.options.apiKey,addr:t.split(/\s+/).join(".")})),e=[];if(n.geometry){const o=s.latLng(n.geometry.lat,n.geometry.lng),i=s.latLngBounds(o,o);e[0]={name:n.words,bbox:i,center:o}}return e}suggest(t){return this.geocode(t)}async reverse(t,n){const e=await d(this.options.serviceUrl+"reverse",g(this.options,{key:this.options.apiKey,coords:[t.lat,t.lng].join(",")})),o=[];if(e.status.status==200){const i=s.latLng(e.geometry.lat,e.geometry.lng),r=s.latLngBounds(i,i);o[0]={name:e.words,bbox:r,center:i}}return o}}function dt(a){return new N(a)}const A=Object.freeze(Object.defineProperty({__proto__:null,ArcGis:x,AzureMaps:C,Bing:U,GeocodeEarth:it,Google:R,HERE:E,HEREv2:k,LatLng:B,MapQuest:S,Mapbox:O,Mapzen:at,Neutrino:K,Nominatim:y,OpenCage:T,OpenLocationCode:P,Openrouteservice:j,Pelias:_,Photon:M,What3Words:N,arcgis:V,azure:F,bing:$,geocodeEarth:rt,geocodingParams:h,google:Q,here:X,latLng:Y,mapQuest:tt,mapbox:Z,mapzen:lt,neutrino:et,nominatim:st,openLocationCode:ot,opencage:nt,openrouteservice:ct,parseLatLng:D,pelias:L,photon:pt,reverseParams:g,what3words:dt},Symbol.toStringTag,{value:"Module"}));class w{constructor(...t){}}s.Util.extend(w.prototype,s.Control.prototype),s.Util.extend(w.prototype,s.Evented.prototype);class b extends w{constructor(n){super(n);p(this,"options",{showUniqueResult:!0,showResultIcons:!1,collapsed:!0,expand:"touch",position:"topright",placeholder:"Search...",errorMessage:"Nothing found.",iconLabel:"Initiate a new search",query:"",queryMinLength:1,suggestMinLength:3,suggestTimeout:250,defaultMarkGeocode:!0});p(this,"_alts");p(this,"_container");p(this,"_errorElement");p(this,"_geocodeMarker");p(this,"_input");p(this,"_lastGeocode");p(this,"_map");p(this,"_preventBlurCollapse");p(this,"_requestCount",0);p(this,"_results");p(this,"_selection");p(this,"_suggestTimeout");s.Util.setOptions(this,n),this.options.geocoder||(this.options.geocoder=new y)}addThrobberClass(){s.DomUtil.addClass(this._container,"leaflet-control-geocoder-throbber")}removeThrobberClass(){s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-throbber")}onAdd(n){var c;const e="leaflet-control-geocoder",o=s.DomUtil.create("div",e+" leaflet-bar"),i=s.DomUtil.create("button",e+"-icon",o),r=s.DomUtil.create("div",e+"-form",o);this._map=n,this._container=o,i.innerHTML=" ",i.type="button",i.setAttribute("aria-label",this.options.iconLabel);const l=this._input=s.DomUtil.create("input","",r);return l.type="search",l.value=this.options.query,l.placeholder=this.options.placeholder,s.DomEvent.disableClickPropagation(l),this._errorElement=s.DomUtil.create("div",e+"-form-no-error",o),this._errorElement.innerHTML=this.options.errorMessage,this._alts=s.DomUtil.create("ul",e+"-alternatives leaflet-control-geocoder-alternatives-minimized",o),s.DomEvent.disableClickPropagation(this._alts),s.DomEvent.addListener(l,"keydown",this._keydown,this),(c=this.options.geocoder)!=null&&c.suggest&&s.DomEvent.addListener(l,"input",this._change,this),s.DomEvent.addListener(l,"blur",()=>{this.options.collapsed&&!this._preventBlurCollapse&&this._collapse(),this._preventBlurCollapse=!1}),this.options.collapsed?this.options.expand==="click"?s.DomEvent.addListener(o,"click",f=>{f.button===0&&f.detail!==2&&this._toggle()}):this.options.expand==="touch"?s.DomEvent.addListener(o,s.Browser.touch?"touchstart mousedown":"mousedown",f=>{this._toggle(),f.preventDefault(),f.stopPropagation()},this):(s.DomEvent.addListener(o,"mouseover",this._expand,this),s.DomEvent.addListener(o,"mouseout",this._collapse,this),this._map.on("movestart",this._collapse,this)):(this._expand(),s.Browser.touch?s.DomEvent.addListener(o,"touchstart",()=>this._geocode()):s.DomEvent.addListener(o,"click",()=>this._geocode())),this.options.defaultMarkGeocode&&this.on("markgeocode",this.markGeocode,this),this.on("startgeocode",this.addThrobberClass,this),this.on("finishgeocode",this.removeThrobberClass,this),this.on("startsuggest",this.addThrobberClass,this),this.on("finishsuggest",this.removeThrobberClass,this),s.DomEvent.disableClickPropagation(o),o}setQuery(n){return this._input.value=n,this}_geocodeResult(n,e){if(!e&&this.options.showUniqueResult&&n.length===1)this._geocodeResultSelected(n[0]);else if(n.length>0){this._alts.innerHTML="",this._results=n,s.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),s.DomUtil.addClass(this._container,"leaflet-control-geocoder-options-open");for(let o=0;o<n.length;o++)this._alts.appendChild(this._createAlt(n[o],o))}else s.DomUtil.addClass(this._container,"leaflet-control-geocoder-options-error"),s.DomUtil.addClass(this._errorElement,"leaflet-control-geocoder-error")}markGeocode(n){const e=n.geocode;return this._map.fitBounds(e.bbox),this._geocodeMarker&&this._map.removeLayer(this._geocodeMarker),this._geocodeMarker=new s.Marker(e.center).bindPopup(e.html||e.name).addTo(this._map).openPopup(),this}async _geocode(n=!1){const e=this._input.value;if(!n&&e.length<this.options.queryMinLength)return;const o=++this._requestCount;this._lastGeocode=e,n||this._clearResults();const i={input:e};this.fire(n?"startsuggest":"startgeocode",i);const r=n?await this.options.geocoder.suggest(e):await this.options.geocoder.geocode(e);if(o===this._requestCount){const l={input:e,results:r};this.fire(n?"finishsuggest":"finishgeocode",l),this._geocodeResult(r,n)}}_geocodeResultSelected(n){const e={geocode:n};this.fire("markgeocode",e)}_toggle(){s.DomUtil.hasClass(this._container,"leaflet-control-geocoder-expanded")?this._collapse():this._expand()}_expand(){s.DomUtil.addClass(this._container,"leaflet-control-geocoder-expanded"),this._input.select(),this.fire("expand")}_collapse(){s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-expanded"),s.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),s.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-open"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-error"),this._input.blur(),this.fire("collapse")}_clearResults(){s.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),this._selection=null,s.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-open"),s.DomUtil.removeClass(this._container,"leaflet-control-geocoder-options-error")}_createAlt(n,e){const o=s.DomUtil.create("li",""),i=s.DomUtil.create("a","",o),r=this.options.showResultIcons&&n.icon?s.DomUtil.create("img","",i):null,l=n.html?void 0:document.createTextNode(n.name),c=f=>{this._preventBlurCollapse=!0,s.DomEvent.stop(f),this._geocodeResultSelected(n),s.DomEvent.on(o,"click touchend",()=>{this.options.collapsed?this._collapse():this._clearResults()})};return r&&(r.src=n.icon),o.setAttribute("data-result-index",String(e)),n.html?i.innerHTML=i.innerHTML+n.html:l&&i.appendChild(l),s.DomEvent.addListener(o,"mousedown touchstart",c,this),o}_keydown(n){const e=o=>{this._selection&&(s.DomUtil.removeClass(this._selection,"leaflet-control-geocoder-selected"),this._selection=this._selection[o>0?"nextSibling":"previousSibling"]),this._selection||(this._selection=this._alts[o>0?"firstChild":"lastChild"]),this._selection&&s.DomUtil.addClass(this._selection,"leaflet-control-geocoder-selected")};switch(n.keyCode){case 27:this.options.collapsed?this._collapse():this._clearResults();break;case 38:e(-1);break;case 40:e(1);break;case 13:if(this._selection){const o=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[o]),this._clearResults()}else this._geocode();break;default:return}s.DomEvent.preventDefault(n)}_change(){const n=this._input.value;n!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),n.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(()=>this._geocode(!0),this.options.suggestTimeout):this._clearResults())}}function G(a){return new b(a)}/* @preserve | ||
* Leaflet Control Geocoder | ||
@@ -8,3 +8,3 @@ * https://github.com/perliedman/leaflet-control-geocoder | ||
* All rights reserved. | ||
*/s.Util.extend(b,P),s.Util.extend(s.Control,{Geocoder:b,geocoder:G}),u.Geocoder=b,u.default=b,u.geocoder=G,u.geocoders=P,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
*/s.Util.extend(b,A),s.Util.extend(s.Control,{Geocoder:b,geocoder:G}),u.Geocoder=b,u.default=b,u.geocoder=G,u.geocoders=A,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
//# sourceMappingURL=Control.Geocoder.js.map |
var N = Object.defineProperty; | ||
var M = (a, t, o) => t in a ? N(a, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : a[t] = o; | ||
var p = (a, t, o) => M(a, typeof t != "symbol" ? t + "" : t, o); | ||
var M = (a, t, n) => t in a ? N(a, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[t] = n; | ||
var p = (a, t, n) => M(a, typeof t != "symbol" ? t + "" : t, n); | ||
import * as s from "leaflet"; | ||
@@ -11,3 +11,3 @@ function u(a, t) { | ||
} | ||
const j = /[&<>"'`]/g, P = /[&<>"'`]/, G = { | ||
const j = /[&<>"'`]/g, A = /[&<>"'`]/, G = { | ||
"&": "&", | ||
@@ -20,20 +20,20 @@ "<": "<", | ||
}; | ||
function A(a) { | ||
function W(a) { | ||
return G[a]; | ||
} | ||
function W(a) { | ||
return a == null ? "" : a ? (a = "" + a, P.test(a) ? a.replace(j, A) : a) : a + ""; | ||
function I(a) { | ||
return a == null ? "" : a ? (a = "" + a, A.test(a) ? a.replace(j, W) : a) : a + ""; | ||
} | ||
function d(a, t) { | ||
const o = { Accept: "application/json" }, e = new URL(a); | ||
return Object.entries(t).forEach(([n, i]) => { | ||
const n = { Accept: "application/json" }, e = new URL(a); | ||
return Object.entries(t).forEach(([o, i]) => { | ||
(Array.isArray(i) ? i : [i]).forEach((r) => { | ||
e.searchParams.append(n, r); | ||
e.searchParams.append(o, r); | ||
}); | ||
}), fetch(e.toString(), { headers: o }).then((n) => n.json()); | ||
}), fetch(e.toString(), { headers: n }).then((o) => o.json()); | ||
} | ||
function I(a, t) { | ||
return a.replace(/\{ *([\w_]+) *\}/g, (o, e) => { | ||
let n = t[e]; | ||
return n === void 0 ? n = "" : typeof n == "function" && (n = n(t)), W(n); | ||
function z(a, t) { | ||
return a.replace(/\{ *([\w_]+) *\}/g, (n, e) => { | ||
let o = t[e]; | ||
return o === void 0 ? o = "" : typeof o == "function" && (o = o(t)), I(o); | ||
}); | ||
@@ -50,3 +50,3 @@ } | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
token: this.options.apiKey, | ||
@@ -60,4 +60,4 @@ SingleLine: t, | ||
this.options.serviceUrl + "/findAddressCandidates", | ||
o | ||
), n = []; | ||
n | ||
), o = []; | ||
if (e.candidates && e.candidates.length) | ||
@@ -69,3 +69,3 @@ for (let i = 0; i <= e.candidates.length - 1; i++) { | ||
); | ||
n[i] = { | ||
o[i] = { | ||
name: r.address, | ||
@@ -76,3 +76,3 @@ bbox: c, | ||
} | ||
return n; | ||
return o; | ||
} | ||
@@ -82,3 +82,3 @@ suggest(t) { | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
@@ -88,7 +88,7 @@ location: t.lng + "," + t.lat, | ||
f: "json" | ||
}), n = await d(this.options.serviceUrl + "/reverseGeocode", e), i = []; | ||
if (n && !n.error) { | ||
const r = s.latLng(n.location.y, n.location.x), l = s.latLngBounds(r, r); | ||
}), o = await d(this.options.serviceUrl + "/reverseGeocode", e), i = []; | ||
if (o && !o.error) { | ||
const r = s.latLng(o.location.y, o.location.x), l = s.latLngBounds(r, r); | ||
i.push({ | ||
name: n.address.Match_addr, | ||
name: o.address.Match_addr, | ||
center: r, | ||
@@ -101,3 +101,3 @@ bbox: l | ||
} | ||
function z(a) { | ||
function q(a) { | ||
return new L(a); | ||
@@ -113,10 +113,10 @@ } | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
query: t, | ||
key: this.options.apiKey | ||
}), e = await d(this.options.serviceUrl, o), n = []; | ||
}), e = await d(this.options.serviceUrl, n), o = []; | ||
if (e.resourceSets.length > 0) | ||
for (let i = e.resourceSets[0].resources.length - 1; i >= 0; i--) { | ||
const r = e.resourceSets[0].resources[i], l = r.bbox; | ||
n[i] = { | ||
o[i] = { | ||
name: r.name, | ||
@@ -127,13 +127,13 @@ bbox: s.latLngBounds([l[0], l[1]], [l[2], l[3]]), | ||
} | ||
return n; | ||
return o; | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
key: this.options.apiKey | ||
}), n = await d( | ||
}), o = await d( | ||
this.options.serviceUrl + t.lat + "," + t.lng, | ||
e | ||
), i = []; | ||
for (let r = n.resourceSets[0].resources.length - 1; r >= 0; r--) { | ||
const l = n.resourceSets[0].resources[r], c = l.bbox; | ||
for (let r = o.resourceSets[0].resources.length - 1; r >= 0; r--) { | ||
const l = o.resourceSets[0].resources[r], c = l.bbox; | ||
i[r] = { | ||
@@ -154,2 +154,59 @@ name: l.name, | ||
p(this, "options", { | ||
apiKey: "", | ||
serviceUrl: "https://atlas.microsoft.com/search" | ||
}); | ||
if (s.Util.setOptions(this, t), !this.options.apiKey) | ||
throw new Error("Azure Maps Geocoder requires an API key."); | ||
} | ||
/** | ||
* {@inheritdoc} | ||
* https://learn.microsoft.com/en-us/rest/api/maps/search/get-search-address?view=rest-maps-1.0&tabs=HTTP | ||
*/ | ||
async geocode(t) { | ||
const n = { | ||
"api-version": "1.0", | ||
query: t, | ||
"subscription-key": this.options.apiKey | ||
}, e = this.options.serviceUrl + "/address/json", o = await d(e, n), i = []; | ||
if (o.results && o.results.length > 0) | ||
for (const r of o.results) | ||
i.push({ | ||
name: r.address.freeformAddress, | ||
bbox: s.latLngBounds( | ||
[r.viewport.topLeftPoint.lat, r.viewport.topLeftPoint.lon], | ||
[r.viewport.btmRightPoint.lat, r.viewport.btmRightPoint.lon] | ||
), | ||
center: s.latLng(r.position.lat, r.position.lon) | ||
}); | ||
return i; | ||
} | ||
/** | ||
* {@inheritdoc} | ||
* https://learn.microsoft.com/en-us/rest/api/maps/search/get-search-address-reverse?view=rest-maps-1.0&tabs=HTTP | ||
*/ | ||
async reverse(t, n) { | ||
const e = { | ||
"api-version": "1.0", | ||
query: t.lat + "," + t.lng, | ||
"subscription-key": this.options.apiKey | ||
}, o = this.options.serviceUrl + "/address/reverse/json", i = await d(o, e), r = []; | ||
if (i.addresses && i.addresses.length > 0) | ||
for (const l of i.addresses) | ||
r.push({ | ||
name: l.address.freeformAddress, | ||
bbox: s.latLngBounds( | ||
[l.viewport.topLeftPoint.lat, l.viewport.topLeftPoint.lon], | ||
[l.viewport.btmRightPoint.lat, l.viewport.btmRightPoint.lon] | ||
), | ||
center: s.latLng(t.lat, t.lng) | ||
}); | ||
return r; | ||
} | ||
} | ||
function J(a) { | ||
return new x(a); | ||
} | ||
class w { | ||
constructor(t) { | ||
p(this, "options", { | ||
serviceUrl: "https://maps.googleapis.com/maps/api/geocode/json" | ||
@@ -160,6 +217,6 @@ }); | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
key: this.options.apiKey, | ||
address: t | ||
}), e = await d(this.options.serviceUrl, o), n = []; | ||
}), e = await d(this.options.serviceUrl, n), o = []; | ||
if (e.results && e.results.length) | ||
@@ -171,3 +228,3 @@ for (let i = 0; i <= e.results.length - 1; i++) { | ||
); | ||
n[i] = { | ||
o[i] = { | ||
name: r.formatted_address, | ||
@@ -179,12 +236,12 @@ bbox: c, | ||
} | ||
return n; | ||
return o; | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
key: this.options.apiKey, | ||
latlng: t.lat + "," + t.lng | ||
}), n = await d(this.options.serviceUrl, e), i = []; | ||
if (n.results && n.results.length) | ||
for (let r = 0; r <= n.results.length - 1; r++) { | ||
const l = n.results[r], c = s.latLng(l.geometry.location), g = s.latLngBounds( | ||
}), o = await d(this.options.serviceUrl, e), i = []; | ||
if (o.results && o.results.length) | ||
for (let r = 0; r <= o.results.length - 1; r++) { | ||
const l = o.results[r], c = s.latLng(l.geometry.location), g = s.latLngBounds( | ||
s.latLng(l.geometry.viewport.northeast), | ||
@@ -203,6 +260,6 @@ s.latLng(l.geometry.viewport.southwest) | ||
} | ||
function J(a) { | ||
return new x(a); | ||
function V(a) { | ||
return new w(a); | ||
} | ||
class w { | ||
class U { | ||
constructor(t) { | ||
@@ -219,3 +276,3 @@ p(this, "options", { | ||
geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
searchtext: t, | ||
@@ -228,8 +285,8 @@ gen: 9, | ||
}); | ||
return this.getJSON(this.options.serviceUrl + "geocode.json", o); | ||
return this.getJSON(this.options.serviceUrl + "geocode.json", n); | ||
} | ||
reverse(t, o) { | ||
reverse(t, n) { | ||
let e = t.lat + "," + t.lng; | ||
this.options.reverseGeocodeProxRadius && (e += "," + this.options.reverseGeocodeProxRadius); | ||
const n = h(this.options, { | ||
const o = h(this.options, { | ||
prox: e, | ||
@@ -243,6 +300,6 @@ mode: "retrieveAddresses", | ||
}); | ||
return this.getJSON(this.options.serviceUrl + "reversegeocode.json", n); | ||
return this.getJSON(this.options.serviceUrl + "reversegeocode.json", o); | ||
} | ||
async getJSON(t, o) { | ||
const e = await d(t, o), n = []; | ||
async getJSON(t, n) { | ||
const e = await d(t, n), o = []; | ||
if (e.response.view && e.response.view.length) | ||
@@ -254,3 +311,3 @@ for (let i = 0; i <= e.response.view[0].result.length - 1; i++) { | ||
); | ||
n[i] = { | ||
o[i] = { | ||
name: r.address.label, | ||
@@ -262,6 +319,6 @@ properties: r.address, | ||
} | ||
return n; | ||
return o; | ||
} | ||
} | ||
class U { | ||
class C { | ||
constructor(t) { | ||
@@ -278,3 +335,3 @@ p(this, "options", { | ||
geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
q: t, | ||
@@ -284,9 +341,9 @@ apiKey: this.options.apiKey, | ||
}); | ||
if (!o.at && !o.in) | ||
if (!n.at && !n.in) | ||
throw Error( | ||
"at / in parameters not found. Please define coordinates (at=latitude,longitude) or other (in) in your geocodingQueryParams." | ||
); | ||
return this.getJSON(this.options.serviceUrl + "/discover", o); | ||
return this.getJSON(this.options.serviceUrl + "/discover", n); | ||
} | ||
reverse(t, o) { | ||
reverse(t, n) { | ||
const e = h(this.options, { | ||
@@ -299,4 +356,4 @@ at: t.lat + "," + t.lng, | ||
} | ||
async getJSON(t, o) { | ||
const e = await d(t, o), n = []; | ||
async getJSON(t, n) { | ||
const e = await d(t, n), o = []; | ||
if (e.items && e.items.length) | ||
@@ -312,3 +369,3 @@ for (let i = 0; i <= e.items.length - 1; i++) { | ||
s.latLng(r.position.lat, r.position.lng) | ||
), n[i] = { | ||
), o[i] = { | ||
name: r.address.label, | ||
@@ -320,9 +377,9 @@ properties: r.address, | ||
} | ||
return n; | ||
return o; | ||
} | ||
} | ||
function q(a) { | ||
return a != null && a.apiKey ? new U(a) : new w(a); | ||
function $(a) { | ||
return a != null && a.apiKey ? new C(a) : new U(a); | ||
} | ||
function C(a) { | ||
function R(a) { | ||
let t; | ||
@@ -379,8 +436,8 @@ if (t = a.match(/^([NS])\s*(\d{1,3}(?:\.\d*)?)\W*([EW])\s*(\d{1,3}(?:\.\d*)?)$/)) | ||
async geocode(t) { | ||
const o = C(t); | ||
return o ? [ | ||
const n = R(t); | ||
return n ? [ | ||
{ | ||
name: t, | ||
center: o, | ||
bbox: o.toBounds(this.options.sizeInMeters) | ||
center: n, | ||
bbox: n.toBounds(this.options.sizeInMeters) | ||
} | ||
@@ -390,6 +447,6 @@ ] : this.options.next ? this.options.next.geocode(t) : []; | ||
} | ||
function V(a) { | ||
function F(a) { | ||
return new E(a); | ||
} | ||
class R { | ||
class k { | ||
constructor(t) { | ||
@@ -402,3 +459,3 @@ p(this, "options", { | ||
_getProperties(t) { | ||
const o = { | ||
const n = { | ||
text: t.text, | ||
@@ -408,14 +465,14 @@ address: t.address | ||
for (let e = 0; e < (t.context || []).length; e++) { | ||
const n = t.context[e].id.split(".")[0]; | ||
o[n] = t.context[e].text, t.context[e].short_code && (o.countryShortCode = t.context[e].short_code); | ||
const o = t.context[e].id.split(".")[0]; | ||
n[o] = t.context[e].text, t.context[e].short_code && (n.countryShortCode = t.context[e].short_code); | ||
} | ||
return o; | ||
return n; | ||
} | ||
async geocode(t) { | ||
const o = this.options.serviceUrl + encodeURIComponent(t) + ".json", e = u(this.options, { | ||
const n = this.options.serviceUrl + encodeURIComponent(t) + ".json", e = u(this.options, { | ||
access_token: this.options.apiKey | ||
}); | ||
e.proximity !== void 0 && e.proximity.lat !== void 0 && e.proximity.lng !== void 0 && (e.proximity = e.proximity.lng + "," + e.proximity.lat); | ||
const n = await d(o, e); | ||
return this._parseResults(n); | ||
const o = await d(n, e); | ||
return this._parseResults(o); | ||
} | ||
@@ -425,6 +482,6 @@ suggest(t) { | ||
} | ||
async reverse(t, o) { | ||
const e = this.options.serviceUrl + t.lng + "," + t.lat + ".json", n = h(this.options, { | ||
async reverse(t, n) { | ||
const e = this.options.serviceUrl + t.lng + "," + t.lat + ".json", o = h(this.options, { | ||
access_token: this.options.apiKey | ||
}), i = await d(e, n); | ||
}), i = await d(e, o); | ||
return this._parseResults(i); | ||
@@ -436,5 +493,5 @@ } | ||
return []; | ||
const o = []; | ||
for (let n = 0; n <= t.features.length - 1; n++) { | ||
const i = t.features[n], r = s.latLng(i.center.reverse()); | ||
const n = []; | ||
for (let o = 0; o <= t.features.length - 1; o++) { | ||
const i = t.features[o], r = s.latLng(i.center.reverse()); | ||
let l; | ||
@@ -444,3 +501,3 @@ i.bbox ? l = s.latLngBounds( | ||
s.latLng(i.bbox.slice(2, 4).reverse()) | ||
) : l = s.latLngBounds(r, r), o[n] = { | ||
) : l = s.latLngBounds(r, r), n[o] = { | ||
name: i.place_name, | ||
@@ -452,7 +509,7 @@ bbox: l, | ||
} | ||
return o; | ||
return n; | ||
} | ||
} | ||
function $(a) { | ||
return new R(a); | ||
function Q(a) { | ||
return new k(a); | ||
} | ||
@@ -467,6 +524,6 @@ class D { | ||
_formatName(...t) { | ||
return t.filter((o) => !!o).join(", "); | ||
return t.filter((n) => !!n).join(", "); | ||
} | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
key: this.options.apiKey, | ||
@@ -476,6 +533,6 @@ location: t, | ||
outFormat: "json" | ||
}), e = await d(this.options.serviceUrl + "/address", o); | ||
}), e = await d(this.options.serviceUrl + "/address", n); | ||
return this._parseResults(e); | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
@@ -485,12 +542,12 @@ key: this.options.apiKey, | ||
outputFormat: "json" | ||
}), n = await d(this.options.serviceUrl + "/reverse", e); | ||
return this._parseResults(n); | ||
}), o = await d(this.options.serviceUrl + "/reverse", e); | ||
return this._parseResults(o); | ||
} | ||
_parseResults(t) { | ||
const o = []; | ||
const n = []; | ||
if (t.results && t.results[0].locations) | ||
for (let e = t.results[0].locations.length - 1; e >= 0; e--) { | ||
const n = t.results[0].locations[e], i = s.latLng(n.latLng); | ||
o[e] = { | ||
name: this._formatName(n.street, n.adminArea4, n.adminArea3, n.adminArea1), | ||
const o = t.results[0].locations[e], i = s.latLng(o.latLng); | ||
n[e] = { | ||
name: this._formatName(o.street, o.adminArea4, o.adminArea3, o.adminArea1), | ||
bbox: s.latLngBounds(i, i), | ||
@@ -500,9 +557,9 @@ center: i | ||
} | ||
return o; | ||
return n; | ||
} | ||
} | ||
function F(a) { | ||
function X(a) { | ||
return new D(a); | ||
} | ||
class k { | ||
class B { | ||
constructor(t) { | ||
@@ -518,3 +575,3 @@ p(this, "options", { | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
apiKey: this.options.apiKey, | ||
@@ -524,7 +581,7 @@ userId: this.options.userId, | ||
address: t.split(/\s+/).join(".") | ||
}), e = await d(this.options.serviceUrl + "geocode-address", o), n = []; | ||
}), e = await d(this.options.serviceUrl + "geocode-address", n), o = []; | ||
if (e.locations) { | ||
e.geometry = e.locations[0]; | ||
const i = s.latLng(e.geometry.latitude, e.geometry.longitude), r = s.latLngBounds(i, i); | ||
n[0] = { | ||
o[0] = { | ||
name: e.geometry.address, | ||
@@ -535,3 +592,3 @@ bbox: r, | ||
} | ||
return n; | ||
return o; | ||
} | ||
@@ -542,3 +599,3 @@ suggest(t) { | ||
// https://www.neutrinoapi.com/api/geocode-reverse/ | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
@@ -549,7 +606,7 @@ apiKey: this.options.apiKey, | ||
longitude: t.lng | ||
}), n = await d(this.options.serviceUrl + "geocode-reverse", e), i = []; | ||
if (n.status.status == 200 && n.found) { | ||
}), o = await d(this.options.serviceUrl + "geocode-reverse", e), i = []; | ||
if (o.status.status == 200 && o.found) { | ||
const r = s.latLng(t.lat, t.lng), l = s.latLngBounds(r, r); | ||
i[0] = { | ||
name: n.address, | ||
name: o.address, | ||
bbox: l, | ||
@@ -562,4 +619,4 @@ center: r | ||
} | ||
function Q(a) { | ||
return new k(a); | ||
function Y(a) { | ||
return new B(a); | ||
} | ||
@@ -570,9 +627,9 @@ class f { | ||
serviceUrl: "https://nominatim.openstreetmap.org/", | ||
htmlTemplate: function(t) { | ||
const o = t.address; | ||
htmlTemplate(t) { | ||
const n = t.address; | ||
let e; | ||
const n = []; | ||
return (o.road || o.building) && n.push("{building} {road} {house_number}"), (o.city || o.town || o.village || o.hamlet) && (e = n.length > 0 ? "leaflet-control-geocoder-address-detail" : "", n.push( | ||
const o = []; | ||
return (n.road || n.building) && o.push("{building} {road} {house_number}"), (n.city || n.town || n.village || n.hamlet) && (e = o.length > 0 ? "leaflet-control-geocoder-address-detail" : "", o.push( | ||
'<span class="' + e + '">{postcode} {city} {town} {village} {hamlet}</span>' | ||
)), (o.state || o.country) && (e = n.length > 0 ? "leaflet-control-geocoder-address-context" : "", n.push('<span class="' + e + '">{state} {country}</span>')), I(n.join("<br/>"), o); | ||
)), (n.state || n.country) && (e = o.length > 0 ? "leaflet-control-geocoder-address-context" : "", o.push('<span class="' + e + '">{state} {country}</span>')), z(o.join("<br/>"), n); | ||
} | ||
@@ -583,3 +640,3 @@ }); | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
q: t, | ||
@@ -589,6 +646,6 @@ limit: 5, | ||
addressdetails: 1 | ||
}), e = await d(this.options.serviceUrl + "search", o), n = []; | ||
}), e = await d(this.options.serviceUrl + "search", n), o = []; | ||
for (let i = e.length - 1; i >= 0; i--) { | ||
const r = e[i].boundingbox; | ||
n[i] = { | ||
o[i] = { | ||
icon: e[i].icon, | ||
@@ -602,20 +659,20 @@ name: e[i].display_name, | ||
} | ||
return n; | ||
return o; | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
lat: t.lat, | ||
lon: t.lng, | ||
zoom: Math.round(Math.log(o / 256) / Math.log(2)), | ||
zoom: Math.round(Math.log(n / 256) / Math.log(2)), | ||
addressdetails: 1, | ||
format: "json" | ||
}), n = await d(this.options.serviceUrl + "reverse", e), i = []; | ||
if (n && n.lat && n.lon) { | ||
const r = s.latLng(+n.lat, +n.lon), l = s.latLngBounds(r, r); | ||
}), o = await d(this.options.serviceUrl + "reverse", e), i = []; | ||
if (o && o.lat && o.lon) { | ||
const r = s.latLng(+o.lat, +o.lon), l = s.latLngBounds(r, r); | ||
i.push({ | ||
name: n.display_name, | ||
html: this.options.htmlTemplate ? this.options.htmlTemplate(n) : void 0, | ||
name: o.display_name, | ||
html: this.options.htmlTemplate ? this.options.htmlTemplate(o) : void 0, | ||
center: r, | ||
bbox: l, | ||
properties: n | ||
properties: o | ||
}); | ||
@@ -626,6 +683,6 @@ } | ||
} | ||
function X(a) { | ||
function Z(a) { | ||
return new f(a); | ||
} | ||
class B { | ||
class K { | ||
constructor(t) { | ||
@@ -637,16 +694,16 @@ p(this, "options", {}); | ||
try { | ||
const o = this.options.OpenLocationCode.decode(t); | ||
const n = this.options.OpenLocationCode.decode(t); | ||
return [{ | ||
name: t, | ||
center: s.latLng(o.latitudeCenter, o.longitudeCenter), | ||
center: s.latLng(n.latitudeCenter, n.longitudeCenter), | ||
bbox: s.latLngBounds( | ||
s.latLng(o.latitudeLo, o.longitudeLo), | ||
s.latLng(o.latitudeHi, o.longitudeHi) | ||
s.latLng(n.latitudeLo, n.longitudeLo), | ||
s.latLng(n.latitudeHi, n.longitudeHi) | ||
) | ||
}]; | ||
} catch (o) { | ||
return console.warn(o), []; | ||
} catch (n) { | ||
return console.warn(n), []; | ||
} | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
try { | ||
@@ -670,4 +727,4 @@ return [{ | ||
} | ||
function Y(a) { | ||
return new B(a); | ||
function tt(a) { | ||
return new K(a); | ||
} | ||
@@ -682,6 +739,6 @@ class S { | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
key: this.options.apiKey, | ||
q: t | ||
}), e = await d(this.options.serviceUrl, o); | ||
}), e = await d(this.options.serviceUrl, n); | ||
return this._parseResults(e); | ||
@@ -692,20 +749,20 @@ } | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
key: this.options.apiKey, | ||
q: [t.lat, t.lng].join(",") | ||
}), n = await d(this.options.serviceUrl, e); | ||
return this._parseResults(n); | ||
}), o = await d(this.options.serviceUrl, e); | ||
return this._parseResults(o); | ||
} | ||
_parseResults(t) { | ||
const o = []; | ||
const n = []; | ||
if (t.results && t.results.length) | ||
for (let e = 0; e < t.results.length; e++) { | ||
const n = t.results[e], i = s.latLng(n.geometry); | ||
const o = t.results[e], i = s.latLng(o.geometry); | ||
let r; | ||
n.annotations && n.annotations.bounds ? r = s.latLngBounds( | ||
s.latLng(n.annotations.bounds.northeast), | ||
s.latLng(n.annotations.bounds.southwest) | ||
) : r = s.latLngBounds(i, i), o.push({ | ||
name: n.formatted, | ||
o.annotations && o.annotations.bounds ? r = s.latLngBounds( | ||
s.latLng(o.annotations.bounds.northeast), | ||
s.latLng(o.annotations.bounds.southwest) | ||
) : r = s.latLngBounds(i, i), n.push({ | ||
name: o.formatted, | ||
bbox: r, | ||
@@ -715,6 +772,6 @@ center: i | ||
} | ||
return o; | ||
return n; | ||
} | ||
} | ||
function Z(a) { | ||
function et(a) { | ||
return new S(a); | ||
@@ -730,16 +787,16 @@ } | ||
async geocode(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
api_key: this.options.apiKey, | ||
text: t | ||
}), e = await d(this.options.serviceUrl + "/search", o); | ||
}), e = await d(this.options.serviceUrl + "/search", n); | ||
return this._parseResults(e, "bbox"); | ||
} | ||
async suggest(t) { | ||
const o = u(this.options, { | ||
const n = u(this.options, { | ||
api_key: this.options.apiKey, | ||
text: t | ||
}), e = await d(this.options.serviceUrl + "/autocomplete", o); | ||
}), e = await d(this.options.serviceUrl + "/autocomplete", n); | ||
return this._parseResults(e, "bbox"); | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
@@ -749,12 +806,12 @@ api_key: this.options.apiKey, | ||
"point.lon": t.lng | ||
}), n = await d(this.options.serviceUrl + "/reverse", e); | ||
return this._parseResults(n, "bounds"); | ||
}), o = await d(this.options.serviceUrl + "/reverse", e); | ||
return this._parseResults(o, "bounds"); | ||
} | ||
_parseResults(t, o) { | ||
_parseResults(t, n) { | ||
const e = []; | ||
return s.geoJSON(t, { | ||
pointToLayer(n, i) { | ||
pointToLayer(o, i) { | ||
return s.circleMarker(i); | ||
}, | ||
onEachFeature(n, i) { | ||
onEachFeature(o, i) { | ||
const r = {}; | ||
@@ -765,3 +822,3 @@ let l, c; | ||
s.GeoJSON.coordsToLatLng(i.feature.bbox.slice(2, 4)) | ||
)) : (c = i.getLatLng(), l = s.latLngBounds(c, c)), r.name = i.feature.properties.label, r.center = c, r[o] = l, r.properties = i.feature.properties, e.push(r); | ||
)) : (c = i.getLatLng(), l = s.latLngBounds(c, c)), r.name = i.feature.properties.label, r.center = c, r[n] = l, r.properties = i.feature.properties, e.push(r); | ||
} | ||
@@ -771,6 +828,6 @@ }), e; | ||
} | ||
function _(a) { | ||
function v(a) { | ||
return new m(a); | ||
} | ||
const tt = m, et = _, st = m, ot = _; | ||
const st = m, ot = v, nt = m, it = v; | ||
class O extends m { | ||
@@ -788,6 +845,6 @@ constructor(t) { | ||
} | ||
function nt(a) { | ||
function rt(a) { | ||
return new O(a); | ||
} | ||
class K { | ||
class P { | ||
constructor(t) { | ||
@@ -802,3 +859,3 @@ p(this, "options", { | ||
async geocode(t) { | ||
const o = u(this.options, { q: t }), e = await d(this.options.serviceUrl, o); | ||
const n = u(this.options, { q: t }), e = await d(this.options.serviceUrl, n); | ||
return this._parseResults(e); | ||
@@ -809,16 +866,16 @@ } | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = h(this.options, { | ||
lat: t.lat, | ||
lon: t.lng | ||
}), n = await d(this.options.reverseUrl, e); | ||
return this._parseResults(n); | ||
}), o = await d(this.options.reverseUrl, e); | ||
return this._parseResults(o); | ||
} | ||
_parseResults(t) { | ||
var e; | ||
const o = []; | ||
const n = []; | ||
if (t && t.features) | ||
for (let n = 0; n < t.features.length; n++) { | ||
const i = t.features[n], r = i.geometry.coordinates, l = s.latLng(r[1], r[0]), c = (e = i.properties) == null ? void 0 : e.extent, g = c ? s.latLngBounds([c[1], c[0]], [c[3], c[2]]) : s.latLngBounds(l, l); | ||
o.push({ | ||
for (let o = 0; o < t.features.length; o++) { | ||
const i = t.features[o], r = i.geometry.coordinates, l = s.latLng(r[1], r[0]), c = (e = i.properties) == null ? void 0 : e.extent, g = c ? s.latLngBounds([c[1], c[0]], [c[3], c[2]]) : s.latLngBounds(l, l); | ||
n.push({ | ||
name: this._decodeFeatureName(i), | ||
@@ -831,13 +888,13 @@ html: this.options.htmlTemplate ? this.options.htmlTemplate(i) : void 0, | ||
} | ||
return o; | ||
return n; | ||
} | ||
_decodeFeatureName(t) { | ||
return (this.options.nameProperties || []).map((o) => { | ||
return (this.options.nameProperties || []).map((n) => { | ||
var e; | ||
return (e = t.properties) == null ? void 0 : e[o]; | ||
}).filter((o) => !!o).join(", "); | ||
return (e = t.properties) == null ? void 0 : e[n]; | ||
}).filter((n) => !!n).join(", "); | ||
} | ||
} | ||
function it(a) { | ||
return new K(a); | ||
function at(a) { | ||
return new P(a); | ||
} | ||
@@ -852,3 +909,3 @@ class T { | ||
async geocode(t) { | ||
const o = await d( | ||
const n = await d( | ||
this.options.serviceUrl + "forward", | ||
@@ -861,8 +918,8 @@ u(this.options, { | ||
), e = []; | ||
if (o.geometry) { | ||
const n = s.latLng(o.geometry.lat, o.geometry.lng), i = s.latLngBounds(n, n); | ||
if (n.geometry) { | ||
const o = s.latLng(n.geometry.lat, n.geometry.lng), i = s.latLngBounds(o, o); | ||
e[0] = { | ||
name: o.words, | ||
name: n.words, | ||
bbox: i, | ||
center: n | ||
center: o | ||
}; | ||
@@ -875,3 +932,3 @@ } | ||
} | ||
async reverse(t, o) { | ||
async reverse(t, n) { | ||
const e = await d( | ||
@@ -883,6 +940,6 @@ this.options.serviceUrl + "reverse", | ||
}) | ||
), n = []; | ||
), o = []; | ||
if (e.status.status == 200) { | ||
const i = s.latLng(e.geometry.lat, e.geometry.lng), r = s.latLngBounds(i, i); | ||
n[0] = { | ||
o[0] = { | ||
name: e.words, | ||
@@ -893,50 +950,52 @@ bbox: r, | ||
} | ||
return n; | ||
return o; | ||
} | ||
} | ||
function rt(a) { | ||
function lt(a) { | ||
return new T(a); | ||
} | ||
const at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ | ||
__proto__: null, | ||
ArcGis: L, | ||
AzureMaps: x, | ||
Bing: y, | ||
GeocodeEarth: tt, | ||
Google: x, | ||
HERE: w, | ||
HEREv2: U, | ||
GeocodeEarth: st, | ||
Google: w, | ||
HERE: U, | ||
HEREv2: C, | ||
LatLng: E, | ||
MapQuest: D, | ||
Mapbox: R, | ||
Mapzen: st, | ||
Neutrino: k, | ||
Mapbox: k, | ||
Mapzen: nt, | ||
Neutrino: B, | ||
Nominatim: f, | ||
OpenCage: S, | ||
OpenLocationCode: B, | ||
OpenLocationCode: K, | ||
Openrouteservice: O, | ||
Pelias: m, | ||
Photon: K, | ||
Photon: P, | ||
What3Words: T, | ||
arcgis: z, | ||
arcgis: q, | ||
azure: J, | ||
bing: H, | ||
geocodeEarth: et, | ||
geocodeEarth: ot, | ||
geocodingParams: u, | ||
google: J, | ||
here: q, | ||
latLng: V, | ||
mapQuest: F, | ||
mapbox: $, | ||
mapzen: ot, | ||
neutrino: Q, | ||
nominatim: X, | ||
openLocationCode: Y, | ||
opencage: Z, | ||
openrouteservice: nt, | ||
parseLatLng: C, | ||
pelias: _, | ||
photon: it, | ||
google: V, | ||
here: $, | ||
latLng: F, | ||
mapQuest: X, | ||
mapbox: Q, | ||
mapzen: it, | ||
neutrino: Y, | ||
nominatim: Z, | ||
openLocationCode: tt, | ||
opencage: et, | ||
openrouteservice: rt, | ||
parseLatLng: R, | ||
pelias: v, | ||
photon: at, | ||
reverseParams: h, | ||
what3words: rt | ||
what3words: lt | ||
}, Symbol.toStringTag, { value: "Module" })); | ||
class v { | ||
class _ { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
@@ -946,5 +1005,5 @@ constructor(...t) { | ||
} | ||
s.Util.extend(v.prototype, s.Control.prototype); | ||
s.Util.extend(v.prototype, s.Evented.prototype); | ||
class b extends v { | ||
s.Util.extend(_.prototype, s.Control.prototype); | ||
s.Util.extend(_.prototype, s.Evented.prototype); | ||
class b extends _ { | ||
/** | ||
@@ -954,4 +1013,4 @@ * Instantiates a geocoder control (to be invoked using `new`) | ||
*/ | ||
constructor(o) { | ||
super(o); | ||
constructor(n) { | ||
super(n); | ||
p(this, "options", { | ||
@@ -984,3 +1043,3 @@ showUniqueResult: !0, | ||
p(this, "_suggestTimeout"); | ||
s.Util.setOptions(this, o), this.options.geocoder || (this.options.geocoder = new f()); | ||
s.Util.setOptions(this, n), this.options.geocoder || (this.options.geocoder = new f()); | ||
} | ||
@@ -998,6 +1057,6 @@ addThrobberClass() { | ||
*/ | ||
onAdd(o) { | ||
onAdd(n) { | ||
var c; | ||
const e = "leaflet-control-geocoder", n = s.DomUtil.create("div", e + " leaflet-bar"), i = s.DomUtil.create("button", e + "-icon", n), r = s.DomUtil.create("div", e + "-form", n); | ||
this._map = o, this._container = n, i.innerHTML = " ", i.type = "button", i.setAttribute("aria-label", this.options.iconLabel); | ||
const e = "leaflet-control-geocoder", o = s.DomUtil.create("div", e + " leaflet-bar"), i = s.DomUtil.create("button", e + "-icon", o), r = s.DomUtil.create("div", e + "-form", o); | ||
this._map = n, this._container = o, i.innerHTML = " ", i.type = "button", i.setAttribute("aria-label", this.options.iconLabel); | ||
const l = this._input = s.DomUtil.create("input", "", r); | ||
@@ -1007,13 +1066,13 @@ return l.type = "search", l.value = this.options.query, l.placeholder = this.options.placeholder, s.DomEvent.disableClickPropagation(l), this._errorElement = s.DomUtil.create( | ||
e + "-form-no-error", | ||
n | ||
o | ||
), this._errorElement.innerHTML = this.options.errorMessage, this._alts = s.DomUtil.create( | ||
"ul", | ||
e + "-alternatives leaflet-control-geocoder-alternatives-minimized", | ||
n | ||
o | ||
), s.DomEvent.disableClickPropagation(this._alts), s.DomEvent.addListener(l, "keydown", this._keydown, this), (c = this.options.geocoder) != null && c.suggest && s.DomEvent.addListener(l, "input", this._change, this), s.DomEvent.addListener(l, "blur", () => { | ||
this.options.collapsed && !this._preventBlurCollapse && this._collapse(), this._preventBlurCollapse = !1; | ||
}), this.options.collapsed ? this.options.expand === "click" ? s.DomEvent.addListener(n, "click", (g) => { | ||
}), this.options.collapsed ? this.options.expand === "click" ? s.DomEvent.addListener(o, "click", (g) => { | ||
g.button === 0 && g.detail !== 2 && this._toggle(); | ||
}) : this.options.expand === "touch" ? s.DomEvent.addListener( | ||
n, | ||
o, | ||
s.Browser.touch ? "touchstart mousedown" : "mousedown", | ||
@@ -1024,3 +1083,3 @@ (g) => { | ||
this | ||
) : (s.DomEvent.addListener(n, "mouseover", this._expand, this), s.DomEvent.addListener(n, "mouseout", this._collapse, this), this._map.on("movestart", this._collapse, this)) : (this._expand(), s.Browser.touch ? s.DomEvent.addListener(n, "touchstart", () => this._geocode()) : s.DomEvent.addListener(n, "click", () => this._geocode())), this.options.defaultMarkGeocode && this.on("markgeocode", this.markGeocode, this), this.on("startgeocode", this.addThrobberClass, this), this.on("finishgeocode", this.removeThrobberClass, this), this.on("startsuggest", this.addThrobberClass, this), this.on("finishsuggest", this.removeThrobberClass, this), s.DomEvent.disableClickPropagation(n), n; | ||
) : (s.DomEvent.addListener(o, "mouseover", this._expand, this), s.DomEvent.addListener(o, "mouseout", this._collapse, this), this._map.on("movestart", this._collapse, this)) : (this._expand(), s.Browser.touch ? s.DomEvent.addListener(o, "touchstart", () => this._geocode()) : s.DomEvent.addListener(o, "click", () => this._geocode())), this.options.defaultMarkGeocode && this.on("markgeocode", this.markGeocode, this), this.on("startgeocode", this.addThrobberClass, this), this.on("finishgeocode", this.removeThrobberClass, this), this.on("startsuggest", this.addThrobberClass, this), this.on("finishsuggest", this.removeThrobberClass, this), s.DomEvent.disableClickPropagation(o), o; | ||
} | ||
@@ -1031,12 +1090,12 @@ /** | ||
*/ | ||
setQuery(o) { | ||
return this._input.value = o, this; | ||
setQuery(n) { | ||
return this._input.value = n, this; | ||
} | ||
_geocodeResult(o, e) { | ||
if (!e && this.options.showUniqueResult && o.length === 1) | ||
this._geocodeResultSelected(o[0]); | ||
else if (o.length > 0) { | ||
this._alts.innerHTML = "", this._results = o, s.DomUtil.removeClass(this._alts, "leaflet-control-geocoder-alternatives-minimized"), s.DomUtil.addClass(this._container, "leaflet-control-geocoder-options-open"); | ||
for (let n = 0; n < o.length; n++) | ||
this._alts.appendChild(this._createAlt(o[n], n)); | ||
_geocodeResult(n, e) { | ||
if (!e && this.options.showUniqueResult && n.length === 1) | ||
this._geocodeResultSelected(n[0]); | ||
else if (n.length > 0) { | ||
this._alts.innerHTML = "", this._results = n, s.DomUtil.removeClass(this._alts, "leaflet-control-geocoder-alternatives-minimized"), s.DomUtil.addClass(this._container, "leaflet-control-geocoder-options-open"); | ||
for (let o = 0; o < n.length; o++) | ||
this._alts.appendChild(this._createAlt(n[o], o)); | ||
} else | ||
@@ -1049,22 +1108,22 @@ s.DomUtil.addClass(this._container, "leaflet-control-geocoder-options-error"), s.DomUtil.addClass(this._errorElement, "leaflet-control-geocoder-error"); | ||
*/ | ||
markGeocode(o) { | ||
const e = o.geocode; | ||
markGeocode(n) { | ||
const e = n.geocode; | ||
return this._map.fitBounds(e.bbox), this._geocodeMarker && this._map.removeLayer(this._geocodeMarker), this._geocodeMarker = new s.Marker(e.center).bindPopup(e.html || e.name).addTo(this._map).openPopup(), this; | ||
} | ||
async _geocode(o = !1) { | ||
async _geocode(n = !1) { | ||
const e = this._input.value; | ||
if (!o && e.length < this.options.queryMinLength) | ||
if (!n && e.length < this.options.queryMinLength) | ||
return; | ||
const n = ++this._requestCount; | ||
this._lastGeocode = e, o || this._clearResults(); | ||
const o = ++this._requestCount; | ||
this._lastGeocode = e, n || this._clearResults(); | ||
const i = { input: e }; | ||
this.fire(o ? "startsuggest" : "startgeocode", i); | ||
const r = o ? await this.options.geocoder.suggest(e) : await this.options.geocoder.geocode(e); | ||
if (n === this._requestCount) { | ||
this.fire(n ? "startsuggest" : "startgeocode", i); | ||
const r = n ? await this.options.geocoder.suggest(e) : await this.options.geocoder.geocode(e); | ||
if (o === this._requestCount) { | ||
const l = { input: e, results: r }; | ||
this.fire(o ? "finishsuggest" : "finishgeocode", l), this._geocodeResult(r, o); | ||
this.fire(n ? "finishsuggest" : "finishgeocode", l), this._geocodeResult(r, n); | ||
} | ||
} | ||
_geocodeResultSelected(o) { | ||
const e = { geocode: o }; | ||
_geocodeResultSelected(n) { | ||
const e = { geocode: n }; | ||
this.fire("markgeocode", e); | ||
@@ -1084,15 +1143,15 @@ } | ||
} | ||
_createAlt(o, e) { | ||
const n = s.DomUtil.create("li", ""), i = s.DomUtil.create("a", "", n), r = this.options.showResultIcons && o.icon ? s.DomUtil.create("img", "", i) : null, l = o.html ? void 0 : document.createTextNode(o.name), c = (g) => { | ||
this._preventBlurCollapse = !0, s.DomEvent.stop(g), this._geocodeResultSelected(o), s.DomEvent.on(n, "click touchend", () => { | ||
_createAlt(n, e) { | ||
const o = s.DomUtil.create("li", ""), i = s.DomUtil.create("a", "", o), r = this.options.showResultIcons && n.icon ? s.DomUtil.create("img", "", i) : null, l = n.html ? void 0 : document.createTextNode(n.name), c = (g) => { | ||
this._preventBlurCollapse = !0, s.DomEvent.stop(g), this._geocodeResultSelected(n), s.DomEvent.on(o, "click touchend", () => { | ||
this.options.collapsed ? this._collapse() : this._clearResults(); | ||
}); | ||
}; | ||
return r && (r.src = o.icon), n.setAttribute("data-result-index", String(e)), o.html ? i.innerHTML = i.innerHTML + o.html : l && i.appendChild(l), s.DomEvent.addListener(n, "mousedown touchstart", c, this), n; | ||
return r && (r.src = n.icon), o.setAttribute("data-result-index", String(e)), n.html ? i.innerHTML = i.innerHTML + n.html : l && i.appendChild(l), s.DomEvent.addListener(o, "mousedown touchstart", c, this), o; | ||
} | ||
_keydown(o) { | ||
const e = (n) => { | ||
this._selection && (s.DomUtil.removeClass(this._selection, "leaflet-control-geocoder-selected"), this._selection = this._selection[n > 0 ? "nextSibling" : "previousSibling"]), this._selection || (this._selection = this._alts[n > 0 ? "firstChild" : "lastChild"]), this._selection && s.DomUtil.addClass(this._selection, "leaflet-control-geocoder-selected"); | ||
_keydown(n) { | ||
const e = (o) => { | ||
this._selection && (s.DomUtil.removeClass(this._selection, "leaflet-control-geocoder-selected"), this._selection = this._selection[o > 0 ? "nextSibling" : "previousSibling"]), this._selection || (this._selection = this._alts[o > 0 ? "firstChild" : "lastChild"]), this._selection && s.DomUtil.addClass(this._selection, "leaflet-control-geocoder-selected"); | ||
}; | ||
switch (o.keyCode) { | ||
switch (n.keyCode) { | ||
// Escape | ||
@@ -1113,4 +1172,4 @@ case 27: | ||
if (this._selection) { | ||
const n = parseInt(this._selection.getAttribute("data-result-index"), 10); | ||
this._geocodeResultSelected(this._results[n]), this._clearResults(); | ||
const o = parseInt(this._selection.getAttribute("data-result-index"), 10); | ||
this._geocodeResultSelected(this._results[o]), this._clearResults(); | ||
} else | ||
@@ -1122,10 +1181,10 @@ this._geocode(); | ||
} | ||
s.DomEvent.preventDefault(o); | ||
s.DomEvent.preventDefault(n); | ||
} | ||
_change() { | ||
const o = this._input.value; | ||
o !== this._lastGeocode && (clearTimeout(this._suggestTimeout), o.length >= this.options.suggestMinLength ? this._suggestTimeout = setTimeout(() => this._geocode(!0), this.options.suggestTimeout) : this._clearResults()); | ||
const n = this._input.value; | ||
n !== this._lastGeocode && (clearTimeout(this._suggestTimeout), n.length >= this.options.suggestMinLength ? this._suggestTimeout = setTimeout(() => this._geocode(!0), this.options.suggestTimeout) : this._clearResults()); | ||
} | ||
} | ||
function lt(a) { | ||
function pt(a) { | ||
return new b(a); | ||
@@ -1141,6 +1200,6 @@ } | ||
*/ | ||
s.Util.extend(b, at); | ||
s.Util.extend(b, ct); | ||
s.Util.extend(s.Control, { | ||
Geocoder: b, | ||
geocoder: lt | ||
geocoder: pt | ||
}); | ||
@@ -1150,5 +1209,5 @@ export { | ||
b as default, | ||
lt as geocoder, | ||
at as geocoders | ||
pt as geocoder, | ||
ct as geocoders | ||
}; | ||
//# sourceMappingURL=Control.Geocoder.modern.js.map |
export * from './api'; | ||
export * from './arcgis'; | ||
export * from './bing'; | ||
export * from './azure'; | ||
export * from './google'; | ||
@@ -5,0 +6,0 @@ export * from './here'; |
{ | ||
"name": "leaflet-control-geocoder", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Extendable geocoder with builtin support for OpenStreetMap Nominatim, Bing, Google, Mapbox, MapQuest, What3Words, Photon, Pelias, HERE, Neutrino, Plus codes", | ||
@@ -27,3 +27,3 @@ "type": "module", | ||
"prepare": "npm run build", | ||
"build": "vite build && tsc --target es2020 --declaration --emitDeclarationOnly --outDir dist/ src/index.ts", | ||
"build": "vite build && tsc --target ES2020 --declaration --emitDeclarationOnly --skipLibCheck --outDir dist/ src/index.ts", | ||
"build:demo": "npm run build:demo-esbuild && npm run build:demo-rollup && npm run build:demo-webpack", | ||
@@ -95,2 +95,2 @@ "build:demo-esbuild": "cd demo-esbuild && npm install && npm run build", | ||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} | ||
} |
@@ -28,2 +28,3 @@ ## A few words on diversity in tech | ||
- [ArcGIS](https://developers.arcgis.com/features/geocoding/) | ||
- [Azure Maps Geocoding](https://www.microsoft.com/en-us/maps/azure/location-services/geocoding) | ||
@@ -30,0 +31,0 @@ The plugin can easily be extended to support other providers. Current extensions: |
export * from './api'; | ||
export * from './arcgis'; | ||
export * from './bing'; | ||
export * from './azure'; | ||
export * from './google'; | ||
@@ -5,0 +6,0 @@ export * from './here'; |
@@ -62,3 +62,3 @@ import * as L from 'leaflet'; | ||
serviceUrl: 'https://nominatim.openstreetmap.org/', | ||
htmlTemplate: function (r: NominatimResult) { | ||
htmlTemplate(r: NominatimResult) { | ||
const address = r.address; | ||
@@ -65,0 +65,0 @@ let className: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
397975
51
4594
92