!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.leafletControlGeocoder=e()}}(function(){return function e(t,o,n){function s(r,a){if(!o[r]){if(!t[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var d=o[r]={exports:{}};t[r][0].call(d.exports,function(e){var o=t[r][1][e];return s(o||e)},d,d.exports,e,t,o,n)}return o[r].exports}for(var i="function"==typeof require&&require,r=0;r0){this._alts.innerHTML="",this._results=e,n.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized");for(var o=0;o0?"nextSibling":"previousSibling"]),t._selection||(t._selection=t._alts[e>0?"firstChild":"lastChild"]),t._selection&&n.DomUtil.addClass(t._selection,"leaflet-control-geocoder-selected")};switch(e.keyCode){case 27:this.options.collapsed&&this._collapse();break;case 38:o(-1);break;case 40:o(1);break;case 13:if(this._selection){var s=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[s]),this._clearResults()}else this._geocode()}},_change:function(e){var t=this._input.value;t!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),t.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(n.bind(function(){this._geocode(!0)},this),this.options.suggestTimeout):this._clearResults())}}),factory:function(e){return new n.Control.Geocoder(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./geocoders/nominatim":9}],2:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{service_url:"http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"},initialize:function(e,t){n.setOptions(this,t),this._accessToken=e},geocode:function(e,t,o){var i={SingleLine:e,outFields:"Addr_Type",forStorage:!1,maxLocations:10,f:"json"};this._key&&this._key.length&&(i.token=this._key),s.getJSON(this.options.service_url+"/findAddressCandidates",i,function(e){var s,i,r,a=[];if(e.candidates&&e.candidates.length)for(var l=0;l<=e.candidates.length-1;l++)s=e.candidates[l],i=n.latLng(s.location.y,s.location.x),r=n.latLngBounds(n.latLng(s.extent.ymax,s.extent.xmax),n.latLng(s.extent.ymin,s.extent.xmin)),a[l]={name:s.address,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r={location:encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat),distance:100,f:"json"};s.getJSON(this.options.service_url+"/reverseGeocode",r,function(e){var t,s=[];e&&!e.error&&(t=n.latLng(e.location.y,e.location.x),s.push({name:e.address.Match_addr,center:t,bounds:n.latLngBounds(t,t)})),o.call(i,s)})}}),factory:function(e,t){return new n.Control.Geocoder.ArcGis(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],3:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({initialize:function(e){this.key=e},geocode:function(e,t,o){s.jsonp("https://dev.virtualearth.net/REST/v1/Locations",{query:e,key:this.key},function(e){var s=[];if(e.resourceSets.length>0)for(var i=e.resourceSets[0].resources.length-1;i>=0;i--){var r=e.resourceSets[0].resources[i],a=r.bbox;s[i]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}t.call(o,s)},this,"jsonp")},reverse:function(e,t,o,i){s.jsonp("//dev.virtualearth.net/REST/v1/Locations/"+e.lat+","+e.lng,{key:this.key},function(e){for(var t=[],s=e.resourceSets[0].resources.length-1;s>=0;s--){var r=e.resourceSets[0].resources[s],a=r.bbox;t[s]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}o.call(i,t)},this,"jsonp")}}),factory:function(e){return new n.Control.Geocoder.Bing(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],4:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){this._key=e,n.setOptions(this,t),this.options.serviceUrl=this.options.service_url||this.options.serviceUrl},geocode:function(e,t,o){var i={address:e};this._key&&this._key.length&&(i.key=this._key),i=n.Util.extend(i,this.options.geocodingQueryParams),s.getJSON(this.options.serviceUrl,i,function(e){var s,i,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)s=e.results[l],i=n.latLng(s.geometry.location),r=n.latLngBounds(n.latLng(s.geometry.viewport.northeast),n.latLng(s.geometry.viewport.southwest)),a[l]={name:s.formatted_address,bbox:r,center:i,properties:s.address_components};t.call(o,a)})},reverse:function(e,t,o,i){var r={latlng:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng)};r=n.Util.extend(r,this.options.reverseQueryParams),this._key&&this._key.length&&(r.key=this._key),s.getJSON(this.options.serviceUrl,r,function(e){var t,s,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)t=e.results[l],s=n.latLng(t.geometry.location),r=n.latLngBounds(n.latLng(t.geometry.viewport.northeast),n.latLng(t.geometry.viewport.southwest)),a[l]={name:t.formatted_address,bbox:r,center:s,properties:t.address_components};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Google(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],5:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{geocodeUrl:"http://geocoder.api.here.com/6.2/geocode.json",reverseGeocodeUrl:"http://reverse.geocoder.api.here.com/6.2/reversegeocode.json",app_id:"",app_code:"",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var s={searchtext:e,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1};s=n.Util.extend(s,this.options.geocodingQueryParams),this.getJSON(this.options.geocodeUrl,s,t,o)},reverse:function(e,t,o,s){var i={prox:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng),mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1};i=n.Util.extend(i,this.options.reverseQueryParams),this.getJSON(this.options.reverseGeocodeUrl,i,o,s)},getJSON:function(e,t,o,i){s.getJSON(e,t,function(e){var t,s,r,a=[];if(e.response.view&&e.response.view.length)for(var l=0;l<=e.response.view[0].result.length-1;l++)t=e.response.view[0].result[l].location,s=n.latLng(t.displayPosition.latitude,t.displayPosition.longitude),r=n.latLngBounds(n.latLng(t.mapView.topLeft.latitude,t.mapView.topLeft.longitude),n.latLng(t.mapView.bottomRight.latitude,t.mapView.bottomRight.longitude)),a[l]={name:t.address.label,bbox:r,center:s};o.call(i,a)})}}),factory:function(e){return new n.Control.Geocoder.HERE(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],6:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){n.setOptions(this,t),this.options.geocodingQueryParams.access_token=e,this.options.reverseQueryParams.access_token=e},geocode:function(e,t,o){var i=this.options.geocodingQueryParams;void 0!==i.proximity&&i.proximity.hasOwnProperty("lat")&&i.proximity.hasOwnProperty("lng")&&(i.proximity=i.proximity.lng+","+i.proximity.lat),s.getJSON(this.options.serviceUrl+encodeURIComponent(e)+".json",i,function(e){var s,i,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)s=e.features[l],i=n.latLng(s.center.reverse()),r=s.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(s.bbox.slice(0,2).reverse()),n.latLng(s.bbox.slice(2,4).reverse())):n.latLngBounds(i,i),a[l]={name:s.place_name,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){s.getJSON(this.options.serviceUrl+encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat)+".json",this.options.reverseQueryParams,function(e){var t,s,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)t=e.features[l],s=n.latLng(t.center.reverse()),r=t.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(t.bbox.slice(0,2).reverse()),n.latLng(t.bbox.slice(2,4).reverse())):n.latLngBounds(s,s),a[l]={name:t.place_name,bbox:r,center:s};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Mapbox(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],7:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"},initialize:function(e,t){this._key=decodeURIComponent(e),n.Util.setOptions(this,t)},_formatName:function(){var e,t=[];for(e=0;e=0;a--)s=e.results[0].locations[a],i=n.latLng(s.latLng),r[a]={name:this._formatName(s.street,s.adminArea4,s.adminArea3,s.adminArea1),bbox:n.latLngBounds(i,i),center:i};t.call(o,r)},this)},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"/reverse",{key:this._key,location:e.lat+","+e.lng,outputFormat:"json"},function(e){var t,s,r=[];if(e.results&&e.results[0].locations)for(var a=e.results[0].locations.length-1;a>=0;a--)t=e.results[0].locations[a],s=n.latLng(t.latLng),r[a]={name:this._formatName(t.street,t.adminArea4,t.adminArea3,t.adminArea1),bbox:n.latLngBounds(s,s),center:s};o.call(i,r)},this)}}),factory:function(e,t){return new n.Control.Geocoder.MapQuest(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],8:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://search.mapzen.com/v1",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){n.Util.setOptions(this,t),this._apiKey=e,this._lastSuggest=0},geocode:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/search",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),function(e){t.call(o,i._parseResults(e,"bbox"))})},suggest:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/autocomplete",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),n.bind(function(e){e.geocoding.timestamp>this._lastSuggest&&(this._lastSuggest=e.geocoding.timestamp,t.call(o,i._parseResults(e,"bbox")))},this))},reverse:function(e,t,o,i){var r=this;s.getJSON(this.options.serviceUrl+"/reverse",n.extend({api_key:this._apiKey,"point.lat":e.lat,"point.lon":e.lng},this.options.reverseQueryParams),function(e){o.call(i,r._parseResults(e,"bounds"))})},_parseResults:function(e,t){var o=[];return n.geoJson(e,{pointToLayer:function(e,t){return n.circleMarker(t)},onEachFeature:function(e,s){var i,r,a={};s.getBounds?(i=s.getBounds(),r=i.getCenter()):(r=s.getLatLng(),i=n.latLngBounds(r,r)),a.name=s.feature.properties.label,a.center=r,a[t]=i,a.properties=s.feature.properties,o.push(a)}}),o}}),factory:function(e,t){return new n.Control.Geocoder.Mapzen(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],9:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://nominatim.openstreetmap.org/",geocodingQueryParams:{},reverseQueryParams:{},htmlTemplate:function(e){var t=e.address,o=[];return(t.road||t.building)&&o.push("{building} {road} {house_number}"),(t.city||t.town||t.village||t.hamlet)&&o.push('{postcode} {city} {town} {village} {hamlet}'),(t.state||t.country)&&o.push('{state} {country}'),s.template(o.join("
"),t,!0)}},initialize:function(e){n.Util.setOptions(this,e)},geocode:function(e,t,o){s.jsonp(this.options.serviceUrl+"search",n.extend({q:e,limit:5,format:"json",addressdetails:1},this.options.geocodingQueryParams),function(e){for(var s=[],i=e.length-1;i>=0;i--){for(var r=e[i].boundingbox,a=0;a<4;a++)r[a]=parseFloat(r[a]);s[i]={icon:e[i].icon,name:e[i].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e[i]):void 0,bbox:n.latLngBounds([r[0],r[2]],[r[1],r[3]]),center:n.latLng(e[i].lat,e[i].lon),properties:e[i]}}t.call(o,s)},this,"json_callback")},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"reverse",n.extend({lat:e.lat,lon:e.lng,zoom:Math.round(Math.log(t/256)/Math.log(2)),addressdetails:1,format:"json"},this.options.reverseQueryParams),function(e){var t,s=[];e&&e.lat&&e.lon&&(t=n.latLng(e.lat,e.lon),s.push({name:e.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e):void 0,center:t,bounds:n.latLngBounds(t,t),properties:e})),o.call(i,s)},this,"json_callback")}}),factory:function(e){return new n.Control.Geocoder.Nominatim(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],10:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:void 0!==o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://photon.komoot.de/api/",reverseUrl:"https://photon.komoot.de/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var i=n.extend({q:e},this.options.geocodingQueryParams);s.getJSON(this.options.serviceUrl,i,n.bind(function(e){t.call(o,this._decodeFeatures(e))},this))},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r=n.extend({lat:e.lat,lon:e.lng},this.options.geocodingQueryParams);s.getJSON(this.options.reverseUrl,r,n.bind(function(e){o.call(i,this._decodeFeatures(e))},this))},_decodeFeatures:function(e){var t,o,s,i,r,a,l=[];if(e&&e.features)for(t=0;t"'`]/g,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return function(n){return null==n?"":n?(n=""+n,o.test(n)?n.replace(t,e):n):n+""}}();t.exports={jsonp:function(e,t,s,i,r){var a="_l_geocoder_"+n++;t[r||"callback"]=a,window[a]=o.Util.bind(s,i);var l=document.createElement("script");l.type="text/javascript",l.src=e+o.Util.getParamString(t),l.id=a,document.getElementsByTagName("head")[0].appendChild(l)},getJSON:function(e,t,n){var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)return 200!==s.status&&304!==s.status?void n(""):void n(JSON.parse(s.response))},s.open("GET",e+o.Util.getParamString(t),!0),s.setRequestHeader("Accept","application/json"),s.send(null)},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,o){var n=t[o];return void 0===n?n="":"function"==typeof n&&(n=n(t)),s(n)})},htmlEscape:s}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[12])(12)});