--- a/src/pyams_gis/resources/js/leaflet-esri-geocoder-2.2.4.min.js Thu Jul 12 17:40:07 2018 +0200
+++ b/src/pyams_gis/resources/js/leaflet-esri-geocoder-2.2.4.min.js Fri Jul 20 12:51:02 2018 +0200
@@ -1,1 +1,1 @@
-(function(b,a){typeof exports==="object"&&typeof module!=="undefined"?a(exports,require("leaflet"),require("esri-leaflet")):typeof define==="function"&&define.amd?define(["exports","leaflet","esri-leaflet"],a):(a((b.L=b.L||{},b.L.esri=b.L.esri||{},b.L.esri.Geocoding=b.L.esri.Geocoding||{}),b.L,b.L.esri))}(this,function(y,g,w){g="default" in g?g["default"]:g;var d="2.2.4";var t=w.Task.extend({path:"findAddressCandidates",params:{outSr:4326,forStorage:false,outFields:"*",maxLocations:20},setters:{address:"address",neighborhood:"neighborhood",city:"city",subregion:"subregion",region:"region",postal:"postal",country:"country",text:"singleLine",category:"category",token:"token",key:"magicKey",fields:"outFields",forStorage:"forStorage",maxLocations:"maxLocations"},initialize:function(z){z=z||{};z.url=z.url||i;w.Task.prototype.initialize.call(this,z)},within:function(z){z=g.latLngBounds(z);this.params.searchExtent=w.Util.boundsToExtent(z);return this},nearby:function(A,z){A=g.latLng(A);this.params.location=A.lng+","+A.lat;this.params.distance=Math.min(Math.max(z,2000),50000);return this},run:function(A,z){if(this.options.customParam){this.params[this.options.customParam]=this.params.singleLine;delete this.params.singleLine}return this.request(function(C,B){var E=this._processGeocoderResponse;var D=(!C)?E(B):undefined;A.call(z,C,{results:D},B)},this)},_processGeocoderResponse:function(z){var B=[];for(var A=0;A<z.candidates.length;A++){var C=z.candidates[A];if(C.extent){var D=w.Util.extentToBounds(C.extent)}B.push({text:C.address,bounds:D,score:C.score,latlng:g.latLng(C.location.y,C.location.x),properties:C.attributes})}return B}});function e(z){return new t(z)}var x=w.Task.extend({path:"reverseGeocode",params:{outSR:4326,returnIntersection:false},setters:{distance:"distance",language:"langCode",intersection:"returnIntersection"},initialize:function(z){z=z||{};z.url=z.url||i;w.Task.prototype.initialize.call(this,z)},latlng:function(z){z=g.latLng(z);this.params.location=z.lng+","+z.lat;return this},run:function(A,z){return this.request(function(D,C){var B;if(!D){B={latlng:g.latLng(C.location.y,C.location.x),address:C.address}}else{B=undefined}A.call(z,D,B,C)},this)}});function m(z){return new x(z)}var l=w.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category",countries:"countryCode",maxSuggestions:"maxSuggestions"},initialize:function(z){z=z||{};if(!z.url){z.url=i;z.supportsSuggest=true}w.Task.prototype.initialize.call(this,z)},within:function(A){A=g.latLngBounds(A);A=A.pad(0.5);var z=A.getCenter();var B=A.getNorthWest();this.params.location=z.lng+","+z.lat;this.params.distance=Math.min(Math.max(z.distanceTo(B),2000),50000);this.params.searchExtent=w.Util.boundsToExtent(A);return this},nearby:function(A,z){A=g.latLng(A);this.params.location=A.lng+","+A.lat;this.params.distance=Math.min(Math.max(z,2000),50000);return this},run:function(A,z){if(this.options.supportsSuggest){return this.request(function(C,B){A.call(z,C,B,B)},this)}else{console.warn("this geocoding service does not support asking for suggestions")}}});function h(z){return new l(z)}var c=w.Service.extend({initialize:function(z){z=z||{};if(z.url){w.Service.prototype.initialize.call(this,z);this._confirmSuggestSupport()}else{z.url=i;z.supportsSuggest=true;w.Service.prototype.initialize.call(this,z)}},geocode:function(){return e(this)},reverse:function(){return m(this)},suggest:function(){return h(this)},_confirmSuggestSupport:function(){this.metadata(function(A,z){if(A){return}if(!z.capabilities){this.options.supportsSuggest=false;this.options.customParam=z.singleLineAddressField.name}else{if(z.capabilities.indexOf("Suggest")>-1){this.options.supportsSuggest=true}else{this.options.supportsSuggest=false}}},this)}});function r(z){return new c(z)}var f=g.Evented.extend({options:{zoomToResult:true,useMapBounds:12,searchBounds:null},initialize:function(A,z){g.Util.setOptions(this,z);this._control=A;if(!z||!z.providers||!z.providers.length){throw new Error("You must specify at least one provider")}this._providers=z.providers},_geocode:function(F,C,E){var A=0;var z=[];var D;var G=g.Util.bind(function(H,I){A--;if(H){return}if(I){z=z.concat(I)}if(A<=0){D=this._boundsFromResults(z);this.fire("results",{results:z,bounds:D,latlng:(D)?D.getCenter():undefined,text:F},true);if(this.options.zoomToResult&&D){this._control._map.fitBounds(D)}this.fire("load")}},this);if(C){A++;E.results(F,C,this._searchBounds(),G)}else{for(var B=0;B<this._providers.length;B++){A++;this._providers[B].results(F,C,this._searchBounds(),G)}}},_suggest:function(E){var A=this._providers.length;var z=g.Util.bind(function(G,F){return g.Util.bind(function(I,H){if(I){return}var J;A=A-1;if(G.length<2){this._suggestions.innerHTML="";this._suggestions.style.display="none";return}if(H.length){for(J=0;J<H.length;J++){H[J].provider=F}}else{this._control._renderSuggestions(H)}if(F._lastRender!==G&&F.nodes){for(J=0;J<F.nodes.length;J++){if(F.nodes[J].parentElement){this._control._suggestions.removeChild(F.nodes[J])}}F.nodes=[]}if(H.length&&this._control._input.value===G){this._control.clearSuggestions(F.nodes);F._lastRender=G;F.nodes=this._control._renderSuggestions(H);this._control._nodes=[]}},this)},this);this._pendingSuggestions=[];for(var B=0;B<this._providers.length;B++){var D=this._providers[B];var C=D.suggestions(E,this._searchBounds(),z(E,D));this._pendingSuggestions.push(C)}},_searchBounds:function(){if(this.options.searchBounds!==null){return this.options.searchBounds}if(this.options.useMapBounds===false){return null}if(this.options.useMapBounds===true){return this._control._map.getBounds()}if(this.options.useMapBounds<=this._control._map.getZoom()){return this._control._map.getBounds()}return null},_boundsFromResults:function(E){if(!E.length){return}var B=g.latLngBounds([0,0],[0,0]);var G=[];var A=[];for(var D=E.length-1;D>=0;D--){var z=E[D];A.push(z.latlng);if(z.bounds&&z.bounds.isValid()&&!z.bounds.equals(B)){G.push(z.bounds)}}var F=g.latLngBounds(A);for(var C=0;C<G.length;C++){F.extend(G[C])}return F},_getAttribution:function(){var B=[];var A=this._providers;for(var z=0;z<A.length;z++){if(A[z].options.attribution){B.push(A[z].options.attribution)}}return B.join(", ")}});function k(A,z){return new f(A,z)}var q=c.extend({options:{label:"Places and Addresses",maxResults:5},suggestions:function(B,A,C){var z=this.suggest().text(B);if(A){z.within(A)}if(this.options.countries){z.countries(this.options.countries)}if(this.options.categories){z.category(this.options.categories)}z.maxSuggestions(this.options.maxResults);return z.run(function(G,H,F){var D=[];if(!G){while(F.suggestions.length&&D.length<=(this.options.maxResults-1)){var E=F.suggestions.shift();if(!E.isCollection){D.push({text:E.text,magicKey:E.magicKey})}}}C(G,D)},this)},results:function(C,z,B,D){var A=this.geocode().text(C);if(z){A.key(z)}A.maxLocations(this.options.maxResults);if(B){A.within(B)}if(this.options.forStorage){A.forStorage(true)}return A.run(function(F,E){D(F,E.results)},this)}});function a(z){return new q(z)}var v=g.Control.extend({includes:g.Mixin.Events,options:{position:"topleft",collapseAfterResult:true,expanded:false,allowMultipleResults:true,placeholder:"Search for places or addresses",title:"Location Search"},initialize:function(z){g.Util.setOptions(this,z);if(!z||!z.providers||!z.providers.length){if(!z){z={}}z.providers=[a()]}this._geosearchCore=k(this,z);this._geosearchCore._providers=z.providers;this._geosearchCore.addEventParent(this);for(var A=0;A<this._geosearchCore._providers.length;A++){this._geosearchCore._providers[A].addEventParent(this)}this._geosearchCore._pendingSuggestions=[];g.Control.prototype.initialize.call(z)},_renderSuggestions:function(E){var G;if(E.length>0){this._suggestions.style.display="block"}this._suggestions.style.maxHeight=(this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10)+"px";var z=[];var F;var D;var H=[];for(var C=0;C<E.length;C++){var B=E[C];if(!D&&this._geosearchCore._providers.length>1&&G!==B.provider.options.label){D=g.DomUtil.create("span","geocoder-control-header",this._suggestions);D.textContent=B.provider.options.label;D.innerText=B.provider.options.label;G=B.provider.options.label;z.push(D)}if(!F){F=g.DomUtil.create("ul","geocoder-control-list",this._suggestions)}if(H.indexOf(B.text)===-1){var I=g.DomUtil.create("li","geocoder-control-suggestion",F);I.innerHTML=B.text;I.provider=B.provider;I["data-magic-key"]=B.magicKey}else{for(var A=0;A<F.childNodes.length;A++){if(F.childNodes[A].innerHTML===B.text){F.childNodes[A]["data-magic-key"]+=","+B.magicKey}}}H.push(B.text)}g.DomUtil.removeClass(this._input,"geocoder-control-loading");z.push(F);return z},_boundsFromResults:function(E){if(!E.length){return}var B=g.latLngBounds([0,0],[0,0]);var G=[];var A=[];for(var D=E.length-1;D>=0;D--){var z=E[D];A.push(z.latlng);if(z.bounds&&z.bounds.isValid()&&!z.bounds.equals(B)){G.push(z.bounds)}}var F=g.latLngBounds(A);for(var C=0;C<G.length;C++){F.extend(G[C])}return F},clear:function(){this._suggestions.innerHTML="";this._suggestions.style.display="none";this._input.value="";if(this.options.collapseAfterResult){this._input.placeholder="";g.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")}if(!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom){this._map.scrollWheelZoom.enable()}},clearSuggestions:function(){if(this._nodes){for(var z=0;z<this._nodes.length;z++){if(this._nodes[z].parentElement){this._suggestions.removeChild(this._nodes[z])}}}},_setupClick:function(){g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");this._input.focus()},disable:function(){this._input.disabled=true;g.DomUtil.addClass(this._input,"geocoder-control-input-disabled");g.DomEvent.removeListener(this._wrapper,"click",this._setupClick,this)},enable:function(){this._input.disabled=false;g.DomUtil.removeClass(this._input,"geocoder-control-input-disabled");g.DomEvent.addListener(this._wrapper,"click",this._setupClick,this)},getAttribution:function(){var A=[];for(var z=0;z<this._providers.length;z++){if(this._providers[z].options.attribution){A.push(this._providers[z].options.attribution)}}return A.join(", ")},onAdd:function(A){w.Util.setEsriAttribution(A);this._map=A;this._wrapper=g.DomUtil.create("div","geocoder-control");this._input=g.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper);this._input.title=this.options.title;if(this.options.expanded){g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");this._input.placeholder=this.options.placeholder}this._suggestions=g.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper);var z=this._geosearchCore._getAttribution();A.attributionControl.addAttribution(z);g.DomEvent.addListener(this._input,"focus",function(B){this._input.placeholder=this.options.placeholder;g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this);g.DomEvent.addListener(this._wrapper,"click",this._setupClick,this);g.DomEvent.addListener(this._suggestions,"mousedown",function(C){var B=C.target||C.srcElement;this._geosearchCore._geocode(B.innerHTML,B["data-magic-key"],B.provider);this.clear()},this);g.DomEvent.addListener(this._input,"blur",function(B){this.clear()},this);g.DomEvent.addListener(this._input,"keydown",function(G){var K=(G.target||G.srcElement).value;g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");var H=this._suggestions.querySelectorAll(".geocoder-control-suggestion");var D=this._suggestions.querySelectorAll(".geocoder-control-selected")[0];var J;for(var E=0;E<H.length;E++){if(H[E]===D){J=E;break}}switch(G.keyCode){case 13:if(D){this._geosearchCore._geocode(D.innerHTML,D["data-magic-key"],D.provider);this.clear()}else{if(this.options.allowMultipleResults&&K.length>=2){this._geosearchCore._geocode(this._input.value,undefined);this.clear()}else{if(H.length===1){g.DomUtil.addClass(H[0],"geocoder-control-selected");this._geosearchCore._geocode(H[0].innerHTML,H[0]["data-magic-key"],H[0].provider)}else{this.clear();this._input.blur()}}}g.DomEvent.preventDefault(G);break;case 38:if(D){g.DomUtil.removeClass(D,"geocoder-control-selected")}var F=H[J-1];if(D&&F){g.DomUtil.addClass(F,"geocoder-control-selected")}else{g.DomUtil.addClass(H[H.length-1],"geocoder-control-selected")}g.DomEvent.preventDefault(G);break;case 40:if(D){g.DomUtil.removeClass(D,"geocoder-control-selected")}var B=H[J+1];if(D&&B){g.DomUtil.addClass(B,"geocoder-control-selected")}else{g.DomUtil.addClass(H[0],"geocoder-control-selected")}g.DomEvent.preventDefault(G);break;default:for(var I=0;I<this._geosearchCore._pendingSuggestions.length;I++){var C=this._geosearchCore._pendingSuggestions[I];if(C&&C.abort&&!C.id){C.abort()}}break}},this);g.DomEvent.addListener(this._input,"keyup",g.Util.throttle(function(C){var B=C.which||C.keyCode;var D=(C.target||C.srcElement).value;if(D.length<2){this._suggestions.innerHTML="";this._suggestions.style.display="none";g.DomUtil.removeClass(this._input,"geocoder-control-loading");return}if(B===27){this._suggestions.innerHTML="";this._suggestions.style.display="none";return}if(B!==13&&B!==38&&B!==40){if(this._input.value!==this._lastValue){this._lastValue=this._input.value;g.DomUtil.addClass(this._input,"geocoder-control-loading");this._geosearchCore._suggest(D)}}},50,this),this);g.DomEvent.disableClickPropagation(this._wrapper);g.DomEvent.addListener(this._suggestions,"mouseover",function(B){if(A.scrollWheelZoom.enabled()&&A.options.scrollWheelZoom){A.scrollWheelZoom.disable()}});g.DomEvent.addListener(this._suggestions,"mouseout",function(B){if(!A.scrollWheelZoom.enabled()&&A.options.scrollWheelZoom){A.scrollWheelZoom.enable()}});this._geosearchCore.on("load",function(B){g.DomUtil.removeClass(this._input,"geocoder-control-loading");this.clear();this._input.blur()},this);return this._wrapper}});function s(z){return new v(z)}var j=w.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1000,formatSuggestion:function(z){return z.properties[this.options.searchFields[0]]}},initialize:function(z){w.FeatureLayerService.prototype.initialize.call(this,z);if(typeof this.options.searchFields==="string"){this.options.searchFields=[this.options.searchFields]}this._suggestionsQuery=this.query();this._resultsQuery=this.query()},suggestions:function(C,A,D){var B=this._suggestionsQuery.where(this._buildQuery(C)).returnGeometry(false);if(A){B.intersects(A)}if(this.options.idField){B.fields([this.options.idField].concat(this.options.searchFields))}var z=B.run(function(G,J,F){if(G){D(G,[])}else{this.options.idField=F.objectIdFieldName;var E=[];for(var I=J.features.length-1;I>=0;I--){var H=J.features[I];E.push({text:this.options.formatSuggestion.call(this,H),magicKey:H.id})}D(G,E.slice(0,this.options.maxResults))}},this);return z},results:function(C,z,A,D){var B=this._resultsQuery;if(z){delete B.params.where;B.featureIds([z])}else{B.where(this._buildQuery(C))}if(A){B.within(A)}return B.run(g.Util.bind(function(F,J){var I=[];for(var H=0;H<J.features.length;H++){var G=J.features[H];if(G){var K=this._featureBounds(G);var E={latlng:K.getCenter(),bounds:K,text:this.options.formatSuggestion.call(this,G),properties:G.properties,geojson:G};I.push(E);delete this._resultsQuery.params.objectIds}}D(F,I)},this))},orderBy:function(A,z){this._suggestionsQuery.orderBy(A,z)},_buildQuery:function(B){var C=[];for(var z=this.options.searchFields.length-1;z>=0;z--){var A='upper("'+this.options.searchFields[z]+'")';C.push(A+" LIKE upper('%"+B+"%')")}if(this.options.where){return this.options.where+" AND ("+C.join(" OR ")+")"}else{return C.join(" OR ")}},_featureBounds:function(B){var A=g.geoJson(B);if(B.geometry.type==="Point"){var z=A.getBounds().getCenter();var D=((this.options.bufferRadius/40075017)*360)/Math.cos((180/Math.PI)*z.lat);var C=(this.options.bufferRadius/40075017)*360;return g.latLngBounds([z.lat-C,z.lng-D],[z.lat+C,z.lng+D])}else{return A.getBounds()}}});function u(z){return new j(z)}var n=w.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1000,maxResults:5,formatSuggestion:function(z){return z.properties[z.displayFieldName]+" <small>"+z.layerName+"</small>"}},initialize:function(z){w.MapService.prototype.initialize.call(this,z);this._getIdFields()},suggestions:function(B,A,C){var z=this.find().text(B).fields(this.options.searchFields).returnGeometry(false).layers(this.options.layers);return z.run(function(J,E,K){var I=[];if(!J){var H=Math.min(this.options.maxResults,E.features.length);K.results=K.results.reverse();for(var F=0;F<H;F++){var L=E.features[F];var M=K.results[F];var G=M.layerId;var D=this._idFields[G];L.layerId=G;L.layerName=this._layerNames[G];L.displayFieldName=this._displayFields[G];if(D){I.push({text:this.options.formatSuggestion.call(this,L),magicKey:M.attributes[D]+":"+G})}}}C(J,I.reverse())},this)},results:function(F,B,D,G){var A=[];var C;if(B){var E=B.split(":")[0];var z=B.split(":")[1];C=this.query().layer(z).featureIds(E)}else{C=this.find().text(F).fields(this.options.searchFields).layers(this.options.layers)}return C.run(function(J,M,I){if(!J){if(I.results){I.results=I.results.reverse()}for(var L=0;L<M.features.length;L++){var K=M.features[L];z=z||I.results[L].layerId;if(K&&z!==undefined){var N=this._featureBounds(K);K.layerId=z;K.layerName=this._layerNames[z];K.displayFieldName=this._displayFields[z];var H={latlng:N.getCenter(),bounds:N,text:this.options.formatSuggestion.call(this,K),properties:K.properties,geojson:K};A.push(H)}}}G(J,A.reverse())},this)},_featureBounds:function(B){var A=g.geoJson(B);if(B.geometry.type==="Point"){var z=A.getBounds().getCenter();var D=((this.options.bufferRadius/40075017)*360)/Math.cos((180/Math.PI)*z.lat);var C=(this.options.bufferRadius/40075017)*360;return g.latLngBounds([z.lat-C,z.lng-D],[z.lat+C,z.lng+D])}else{return A.getBounds()}},_layerMetadataCallback:function(z){return g.Util.bind(function(A,C){if(A){return}this._displayFields[z]=C.displayField;this._layerNames[z]=C.name;for(var B=0;B<C.fields.length;B++){var D=C.fields[B];if(D.type==="esriFieldTypeOID"){this._idFields[z]=D.name;break}}},this)},_getIdFields:function(){this._idFields={};this._displayFields={};this._layerNames={};for(var A=0;A<this.options.layers.length;A++){var z=this.options.layers[A];this.get(z,{},this._layerMetadataCallback(z))}}});function b(z){return new n(z)}var o=c.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(B,A,C){if(this.options.supportsSuggest){var z=this.suggest().text(B);if(A){z.within(A)}return z.run(function(G,H,F){var D=[];if(!G){while(F.suggestions.length&&D.length<=(this.options.maxResults-1)){var E=F.suggestions.shift();if(!E.isCollection){D.push({text:E.text,magicKey:E.magicKey})}}}C(G,D)},this)}else{C(undefined,[]);return false}},results:function(C,z,B,D){var A=this.geocode().text(C);A.maxLocations(this.options.maxResults);if(B){A.within(B)}return A.run(function(F,E){D(F,E.results)},this)}});function p(z){return new o(z)}var i="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";y.WorldGeocodingServiceUrl=i;y.VERSION=d;y.Geocode=t;y.geocode=e;y.ReverseGeocode=x;y.reverseGeocode=m;y.Suggest=l;y.suggest=h;y.GeocodeService=c;y.geocodeService=r;y.Geosearch=v;y.geosearch=s;y.GeosearchCore=f;y.geosearchCore=k;y.ArcgisOnlineProvider=q;y.arcgisOnlineProvider=a;y.FeatureLayerProvider=j;y.featureLayerProvider=u;y.MapServiceProvider=n;y.mapServiceProvider=b;y.GeocodeServiceProvider=o;y.geocodeServiceProvider=p}));
\ No newline at end of file
+q(function(b,a){typeof exports==="object"&&typeof module!=="undefined"?a(exports,require("leaflet"),require("esri-leaflet")):typeof define==="function"&&define.amd?define(["exports","leaflet","esri-leaflet"],a):(a((b.L=b.L||{},b.L.esri=b.L.esri||{},b.L.esri.Geocoding=b.L.esri.Geocoding||{}),b.L,b.L.esri))}(this,function(y,g,w){g="default" in g?g["default"]:g;var d="2.2.4";var t=w.Task.extend({path:"findAddressCandidates",params:{outSr:4326,forStorage:false,outFields:"*",maxLocations:20},setters:{address:"address",neighborhood:"neighborhood",city:"city",subregion:"subregion",region:"region",postal:"postal",country:"country",text:"singleLine",category:"category",token:"token",key:"magicKey",fields:"outFields",forStorage:"forStorage",maxLocations:"maxLocations"},initialize:function(z){z=z||{};z.url=z.url||i;w.Task.prototype.initialize.call(this,z)},within:function(z){z=g.latLngBounds(z);this.params.searchExtent=w.Util.boundsToExtent(z);return this},nearby:function(A,z){A=g.latLng(A);this.params.location=A.lng+","+A.lat;this.params.distance=Math.min(Math.max(z,2000),50000);return this},run:function(A,z){if(this.options.customParam){this.params[this.options.customParam]=this.params.singleLine;delete this.params.singleLine}return this.request(function(C,B){var E=this._processGeocoderResponse;var D=(!C)?E(B):undefined;A.call(z,C,{results:D},B)},this)},_processGeocoderResponse:function(z){var B=[];for(var A=0;A<z.candidates.length;A++){var C=z.candidates[A];if(C.extent){var D=w.Util.extentToBounds(C.extent)}B.push({text:C.address,bounds:D,score:C.score,latlng:g.latLng(C.location.y,C.location.x),properties:C.attributes})}return B}});function e(z){return new t(z)}var x=w.Task.extend({path:"reverseGeocode",params:{outSR:4326,returnIntersection:false},setters:{distance:"distance",language:"langCode",intersection:"returnIntersection"},initialize:function(z){z=z||{};z.url=z.url||i;w.Task.prototype.initialize.call(this,z)},latlng:function(z){z=g.latLng(z);this.params.location=z.lng+","+z.lat;return this},run:function(A,z){return this.request(function(D,C){var B;if(!D){B={latlng:g.latLng(C.location.y,C.location.x),address:C.address}}else{B=undefined}A.call(z,D,B,C)},this)}});function m(z){return new x(z)}var l=w.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category",countries:"countryCode",maxSuggestions:"maxSuggestions"},initialize:function(z){z=z||{};if(!z.url){z.url=i;z.supportsSuggest=true}w.Task.prototype.initialize.call(this,z)},within:function(A){A=g.latLngBounds(A);A=A.pad(0.5);var z=A.getCenter();var B=A.getNorthWest();this.params.location=z.lng+","+z.lat;this.params.distance=Math.min(Math.max(z.distanceTo(B),2000),50000);this.params.searchExtent=w.Util.boundsToExtent(A);return this},nearby:function(A,z){A=g.latLng(A);this.params.location=A.lng+","+A.lat;this.params.distance=Math.min(Math.max(z,2000),50000);return this},run:function(A,z){if(this.options.supportsSuggest){return this.request(function(C,B){A.call(z,C,B,B)},this)}else{console.warn("this geocoding service does not support asking for suggestions")}}});function h(z){return new l(z)}var c=w.Service.extend({initialize:function(z){z=z||{};if(z.url){w.Service.prototype.initialize.call(this,z);this._confirmSuggestSupport()}else{z.url=i;z.supportsSuggest=true;w.Service.prototype.initialize.call(this,z)}},geocode:function(){return e(this)},reverse:function(){return m(this)},suggest:function(){return h(this)},_confirmSuggestSupport:function(){this.metadata(function(A,z){if(A){return}if(!z.capabilities){this.options.supportsSuggest=false;this.options.customParam=z.singleLineAddressField.name}else{if(z.capabilities.indexOf("Suggest")>-1){this.options.supportsSuggest=true}else{this.options.supportsSuggest=false}}},this)}});function r(z){return new c(z)}var f=g.Evented.extend({options:{zoomToResult:true,useMapBounds:12,searchBounds:null},initialize:function(A,z){g.Util.setOptions(this,z);this._control=A;if(!z||!z.providers||!z.providers.length){throw new Error("You must specify at least one provider")}this._providers=z.providers},_geocode:function(F,C,E){var A=0;var z=[];var D;var G=g.Util.bind(function(H,I){A--;if(H){return}if(I){z=z.concat(I)}if(A<=0){D=this._boundsFromResults(z);this.fire("results",{results:z,bounds:D,latlng:(D)?D.getCenter():undefined,text:F},true);if(this.options.zoomToResult&&D){this._control._map.fitBounds(D)}this.fire("load")}},this);if(C){A++;E.results(F,C,this._searchBounds(),G)}else{for(var B=0;B<this._providers.length;B++){A++;this._providers[B].results(F,C,this._searchBounds(),G)}}},_suggest:function(E){var A=this._providers.length;var z=g.Util.bind(function(G,F){return g.Util.bind(function(I,H){if(I){return}var J;A=A-1;if(G.length<2){this._suggestions.innerHTML="";this._suggestions.style.display="none";return}if(H.length){for(J=0;J<H.length;J++){H[J].provider=F}}else{this._control._renderSuggestions(H)}if(F._lastRender!==G&&F.nodes){for(J=0;J<F.nodes.length;J++){if(F.nodes[J].parentElement){this._control._suggestions.removeChild(F.nodes[J])}}F.nodes=[]}if(H.length&&this._control._input.value===G){this._control.clearSuggestions(F.nodes);F._lastRender=G;F.nodes=this._control._renderSuggestions(H);this._control._nodes=[]}},this)},this);this._pendingSuggestions=[];for(var B=0;B<this._providers.length;B++){var D=this._providers[B];var C=D.suggestions(E,this._searchBounds(),z(E,D));this._pendingSuggestions.push(C)}},_searchBounds:function(){if(this.options.searchBounds!==null){return this.options.searchBounds}if(this.options.useMapBounds===false){return null}if(this.options.useMapBounds===true){return this._control._map.getBounds()}if(this.options.useMapBounds<=this._control._map.getZoom()){return this._control._map.getBounds()}return null},_boundsFromResults:function(E){if(!E.length){return}var B=g.latLngBounds([0,0],[0,0]);var G=[];var A=[];for(var D=E.length-1;D>=0;D--){var z=E[D];A.push(z.latlng);if(z.bounds&&z.bounds.isValid()&&!z.bounds.equals(B)){G.push(z.bounds)}}var F=g.latLngBounds(A);for(var C=0;C<G.length;C++){F.extend(G[C])}return F},_getAttribution:function(){var B=[];var A=this._providers;for(var z=0;z<A.length;z++){if(A[z].options.attribution){B.push(A[z].options.attribution)}}return B.join(", ")}});function k(A,z){return new f(A,z)}var q=c.extend({options:{label:"Places and Addresses",maxResults:5},suggestions:function(B,A,C){var z=this.suggest().text(B);if(A){z.within(A)}if(this.options.countries){z.countries(this.options.countries)}if(this.options.categories){z.category(this.options.categories)}z.maxSuggestions(this.options.maxResults);return z.run(function(G,H,F){var D=[];if(!G){while(F.suggestions.length&&D.length<=(this.options.maxResults-1)){var E=F.suggestions.shift();if(!E.isCollection){D.push({text:E.text,magicKey:E.magicKey})}}}C(G,D)},this)},results:function(C,z,B,D){var A=this.geocode().text(C);if(z){A.key(z)}A.maxLocations(this.options.maxResults);if(B){A.within(B)}if(this.options.forStorage){A.forStorage(true)}return A.run(function(F,E){D(F,E.results)},this)}});function a(z){return new q(z)}var v=g.Control.extend({includes:g.Mixin.Events,options:{position:"topleft",collapseAfterResult:true,expanded:false,allowMultipleResults:true,placeholder:"Search for places or addresses",title:"Location Search"},initialize:function(z){g.Util.setOptions(this,z);if(!z||!z.providers||!z.providers.length){if(!z){z={}}z.providers=[a()]}this._geosearchCore=k(this,z);this._geosearchCore._providers=z.providers;this._geosearchCore.addEventParent(this);for(var A=0;A<this._geosearchCore._providers.length;A++){this._geosearchCore._providers[A].addEventParent(this)}this._geosearchCore._pendingSuggestions=[];g.Control.prototype.initialize.call(z)},_renderSuggestions:function(E){var G;if(E.length>0){this._suggestions.style.display="block"}this._suggestions.style.maxHeight=(this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10)+"px";var z=[];var F;var D;var H=[];for(var C=0;C<E.length;C++){var B=E[C];if(!D&&this._geosearchCore._providers.length>1&&G!==B.provider.options.label){D=g.DomUtil.create("span","geocoder-control-header",this._suggestions);D.textContent=B.provider.options.label;D.innerText=B.provider.options.label;G=B.provider.options.label;z.push(D)}if(!F){F=g.DomUtil.create("ul","geocoder-control-list",this._suggestions)}if(H.indexOf(B.text)===-1){var I=g.DomUtil.create("li","geocoder-control-suggestion",F);I.innerHTML=B.text;I.provider=B.provider;I["data-magic-key"]=B.magicKey}else{for(var A=0;A<F.childNodes.length;A++){if(F.childNodes[A].innerHTML===B.text){F.childNodes[A]["data-magic-key"]+=","+B.magicKey}}}H.push(B.text)}g.DomUtil.removeClass(this._input,"geocoder-control-loading");z.push(F);return z},_boundsFromResults:function(E){if(!E.length){return}var B=g.latLngBounds([0,0],[0,0]);var G=[];var A=[];for(var D=E.length-1;D>=0;D--){var z=E[D];A.push(z.latlng);if(z.bounds&&z.bounds.isValid()&&!z.bounds.equals(B)){G.push(z.bounds)}}var F=g.latLngBounds(A);for(var C=0;C<G.length;C++){F.extend(G[C])}return F},clear:function(){this._suggestions.innerHTML="";this._suggestions.style.display="none";this._input.value="";if(this.options.collapseAfterResult){this._input.placeholder="";g.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")}if(!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom){this._map.scrollWheelZoom.enable()}},clearSuggestions:function(){if(this._nodes){for(var z=0;z<this._nodes.length;z++){if(this._nodes[z].parentElement){this._suggestions.removeChild(this._nodes[z])}}}},_setupClick:function(){g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");this._input.focus()},disable:function(){this._input.disabled=true;g.DomUtil.addClass(this._input,"geocoder-control-input-disabled");g.DomEvent.removeListener(this._wrapper,"click",this._setupClick,this)},enable:function(){this._input.disabled=false;g.DomUtil.removeClass(this._input,"geocoder-control-input-disabled");g.DomEvent.addListener(this._wrapper,"click",this._setupClick,this)},getAttribution:function(){var A=[];for(var z=0;z<this._providers.length;z++){if(this._providers[z].options.attribution){A.push(this._providers[z].options.attribution)}}return A.join(", ")},onAdd:function(A){w.Util.setEsriAttribution(A);this._map=A;this._wrapper=g.DomUtil.create("div","geocoder-control");this._input=g.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper);this._input.title=this.options.title;if(this.options.expanded){g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");this._input.placeholder=this.options.placeholder}this._suggestions=g.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper);var z=this._geosearchCore._getAttribution();A.attributionControl.addAttribution(z);g.DomEvent.addListener(this._input,"focus",function(B){this._input.placeholder=this.options.placeholder;g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this);g.DomEvent.addListener(this._wrapper,"click",this._setupClick,this);g.DomEvent.addListener(this._suggestions,"mousedown",function(C){var B=C.target||C.srcElement;this._geosearchCore._geocode(B.innerHTML,B["data-magic-key"],B.provider);this.clear()},this);g.DomEvent.addListener(this._input,"blur",function(B){this.clear()},this);g.DomEvent.addListener(this._input,"keydown",function(G){var K=(G.target||G.srcElement).value;g.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");var H=this._suggestions.querySelectorAll(".geocoder-control-suggestion");var D=this._suggestions.querySelectorAll(".geocoder-control-selected")[0];var J;for(var E=0;E<H.length;E++){if(H[E]===D){J=E;break}}switch(G.keyCode){case 13:if(D){this._geosearchCore._geocode(D.innerHTML,D["data-magic-key"],D.provider);this.clear()}else{if(this.options.allowMultipleResults&&K.length>=2){this._geosearchCore._geocode(this._input.value,undefined);this.clear()}else{if(H.length===1){g.DomUtil.addClass(H[0],"geocoder-control-selected");this._geosearchCore._geocode(H[0].innerHTML,H[0]["data-magic-key"],H[0].provider)}else{this.clear();this._input.blur()}}}g.DomEvent.preventDefault(G);break;case 38:if(D){g.DomUtil.removeClass(D,"geocoder-control-selected")}var F=H[J-1];if(D&&F){g.DomUtil.addClass(F,"geocoder-control-selected")}else{g.DomUtil.addClass(H[H.length-1],"geocoder-control-selected")}g.DomEvent.preventDefault(G);break;case 40:if(D){g.DomUtil.removeClass(D,"geocoder-control-selected")}var B=H[J+1];if(D&&B){g.DomUtil.addClass(B,"geocoder-control-selected")}else{g.DomUtil.addClass(H[0],"geocoder-control-selected")}g.DomEvent.preventDefault(G);break;default:for(var I=0;I<this._geosearchCore._pendingSuggestions.length;I++){var C=this._geosearchCore._pendingSuggestions[I];if(C&&C.abort&&!C.id){C.abort()}}break}},this);g.DomEvent.addListener(this._input,"keyup",g.Util.throttle(function(C){var B=C.which||C.keyCode;var D=(C.target||C.srcElement).value;if(D.length<2){this._suggestions.innerHTML="";this._suggestions.style.display="none";g.DomUtil.removeClass(this._input,"geocoder-control-loading");return}if(B===27){this._suggestions.innerHTML="";this._suggestions.style.display="none";return}if(B!==13&&B!==38&&B!==40){if(this._input.value!==this._lastValue){this._lastValue=this._input.value;g.DomUtil.addClass(this._input,"geocoder-control-loading");this._geosearchCore._suggest(D)}}},50,this),this);g.DomEvent.disableClickPropagation(this._wrapper);g.DomEvent.addListener(this._suggestions,"mouseover",function(B){if(A.scrollWheelZoom.enabled()&&A.options.scrollWheelZoom){A.scrollWheelZoom.disable()}});g.DomEvent.addListener(this._suggestions,"mouseout",function(B){if(!A.scrollWheelZoom.enabled()&&A.options.scrollWheelZoom){A.scrollWheelZoom.enable()}});this._geosearchCore.on("load",function(B){g.DomUtil.removeClass(this._input,"geocoder-control-loading");this.clear();this._input.blur()},this);return this._wrapper}});function s(z){return new v(z)}var j=w.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1000,formatSuggestion:function(z){return z.properties[this.options.searchFields[0]]}},initialize:function(z){w.FeatureLayerService.prototype.initialize.call(this,z);if(typeof this.options.searchFields==="string"){this.options.searchFields=[this.options.searchFields]}this._suggestionsQuery=this.query();this._resultsQuery=this.query()},suggestions:function(C,A,D){var B=this._suggestionsQuery.where(this._buildQuery(C)).returnGeometry(false);if(A){B.intersects(A)}if(this.options.idField){B.fields([this.options.idField].concat(this.options.searchFields))}var z=B.run(function(G,J,F){if(G){D(G,[])}else{this.options.idField=F.objectIdFieldName;var E=[];for(var I=J.features.length-1;I>=0;I--){var H=J.features[I];E.push({text:this.options.formatSuggestion.call(this,H),magicKey:H.id})}D(G,E.slice(0,this.options.maxResults))}},this);return z},results:function(C,z,A,D){var B=this._resultsQuery;if(z){delete B.params.where;B.featureIds([z])}else{B.where(this._buildQuery(C))}if(A){B.within(A)}return B.run(g.Util.bind(function(F,J){var I=[];for(var H=0;H<J.features.length;H++){var G=J.features[H];if(G){var K=this._featureBounds(G);var E={latlng:K.getCenter(),bounds:K,text:this.options.formatSuggestion.call(this,G),properties:G.properties,geojson:G};I.push(E);delete this._resultsQuery.params.objectIds}}D(F,I)},this))},orderBy:function(A,z){this._suggestionsQuery.orderBy(A,z)},_buildQuery:function(B){var C=[];for(var z=this.options.searchFields.length-1;z>=0;z--){var A='upper("'+this.options.searchFields[z]+'")';C.push(A+" LIKE upper('%"+B+"%')")}if(this.options.where){return this.options.where+" AND ("+C.join(" OR ")+")"}else{return C.join(" OR ")}},_featureBounds:function(B){var A=g.geoJson(B);if(B.geometry.type==="Point"){var z=A.getBounds().getCenter();var D=((this.options.bufferRadius/40075017)*360)/Math.cos((180/Math.PI)*z.lat);var C=(this.options.bufferRadius/40075017)*360;return g.latLngBounds([z.lat-C,z.lng-D],[z.lat+C,z.lng+D])}else{return A.getBounds()}}});function u(z){return new j(z)}var n=w.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1000,maxResults:5,formatSuggestion:function(z){return z.properties[z.displayFieldName]+" <small>"+z.layerName+"</small>"}},initialize:function(z){w.MapService.prototype.initialize.call(this,z);this._getIdFields()},suggestions:function(B,A,C){var z=this.find().text(B).fields(this.options.searchFields).returnGeometry(false).layers(this.options.layers);return z.run(function(J,E,K){var I=[];if(!J){var H=Math.min(this.options.maxResults,E.features.length);K.results=K.results.reverse();for(var F=0;F<H;F++){var L=E.features[F];var M=K.results[F];var G=M.layerId;var D=this._idFields[G];L.layerId=G;L.layerName=this._layerNames[G];L.displayFieldName=this._displayFields[G];if(D){I.push({text:this.options.formatSuggestion.call(this,L),magicKey:M.attributes[D]+":"+G})}}}C(J,I.reverse())},this)},results:function(F,B,D,G){var A=[];var C;if(B){var E=B.split(":")[0];var z=B.split(":")[1];C=this.query().layer(z).featureIds(E)}else{C=this.find().text(F).fields(this.options.searchFields).layers(this.options.layers)}return C.run(function(J,M,I){if(!J){if(I.results){I.results=I.results.reverse()}for(var L=0;L<M.features.length;L++){var K=M.features[L];z=z||I.results[L].layerId;if(K&&z!==undefined){var N=this._featureBounds(K);K.layerId=z;K.layerName=this._layerNames[z];K.displayFieldName=this._displayFields[z];var H={latlng:N.getCenter(),bounds:N,text:this.options.formatSuggestion.call(this,K),properties:K.properties,geojson:K};A.push(H)}}}G(J,A.reverse())},this)},_featureBounds:function(B){var A=g.geoJson(B);if(B.geometry.type==="Point"){var z=A.getBounds().getCenter();var D=((this.options.bufferRadius/40075017)*360)/Math.cos((180/Math.PI)*z.lat);var C=(this.options.bufferRadius/40075017)*360;return g.latLngBounds([z.lat-C,z.lng-D],[z.lat+C,z.lng+D])}else{return A.getBounds()}},_layerMetadataCallback:function(z){return g.Util.bind(function(A,C){if(A){return}this._displayFields[z]=C.displayField;this._layerNames[z]=C.name;for(var B=0;B<C.fields.length;B++){var D=C.fields[B];if(D.type==="esriFieldTypeOID"){this._idFields[z]=D.name;break}}},this)},_getIdFields:function(){this._idFields={};this._displayFields={};this._layerNames={};for(var A=0;A<this.options.layers.length;A++){var z=this.options.layers[A];this.get(z,{},this._layerMetadataCallback(z))}}});function b(z){return new n(z)}var o=c.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(B,A,C){if(this.options.supportsSuggest){var z=this.suggest().text(B);if(A){z.within(A)}return z.run(function(G,H,F){var D=[];if(!G){while(F.suggestions.length&&D.length<=(this.options.maxResults-1)){var E=F.suggestions.shift();if(!E.isCollection){D.push({text:E.text,magicKey:E.magicKey})}}}C(G,D)},this)}else{C(undefined,[]);return false}},results:function(C,z,B,D){var A=this.geocode().text(C);A.maxLocations(this.options.maxResults);if(B){A.within(B)}return A.run(function(F,E){D(F,E.results)},this)}});function p(z){return new o(z)}var i="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";y.WorldGeocodingServiceUrl=i;y.VERSION=d;y.Geocode=t;y.geocode=e;y.ReverseGeocode=x;y.reverseGeocode=m;y.Suggest=l;y.suggest=h;y.GeocodeService=c;y.geocodeService=r;y.Geosearch=v;y.geosearch=s;y.GeosearchCore=f;y.geosearchCore=k;y.ArcgisOnlineProvider=q;y.arcgisOnlineProvider=a;y.FeatureLayerProvider=j;y.featureLayerProvider=u;y.MapServiceProvider=n;y.mapServiceProvider=b;y.GeocodeServiceProvider=o;y.geocodeServiceProvider=p}));