esri-leaflet-geocoder
Advanced tools
Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "esri-leaflet-geocoder", | ||
"version": "v2.1.1", | ||
"main": "dist/esri-leaflet-geocoder.js", | ||
"dependencies": { | ||
"esri-leaflet": "^2.0.0", | ||
"leaflet": "^1.0.0-rc.1" | ||
"esri-leaflet": "^2.0.3", | ||
"leaflet": "^1.0.0-rc.3" | ||
}, | ||
@@ -10,0 +9,0 @@ "ignore": [ |
@@ -5,2 +5,13 @@ # Changelog | ||
## [2.1.2] | ||
### Fixed | ||
* 'Powered by Esri' is now displayed in map attribution when the ArcGIS Online World Geocoding service is used in geosearch instead of 'Geocoding by Esri' [#134](https://github.com/Esri/esri-leaflet-geocoder/pull/134) | ||
### Added | ||
* We now expose a `where` constructor parameter for featureLayerProvider so that developers can filter features which will be matched to user searches. [#136](https://github.com/Esri/esri-leaflet-geocoder/pull/136) | ||
* The geosearch control now utilizes the `arcgisOnlineProvider` by default if no provider is specified in the object constructor. [#137](https://github.com/Esri/esri-leaflet-geocoder/pull/137) | ||
## [2.1.1] | ||
@@ -14,3 +25,3 @@ | ||
* improved support for custom Esri geocoding services in `geosearch` [#121](https://github.com/Esri/esri-leaflet-geocoder/pull/121) | ||
* improved support for custom Esri geocoding services in `geosearch` [#124](https://github.com/Esri/esri-leaflet-geocoder/pull/124) | ||
@@ -210,3 +221,4 @@ ## [2.1.0] | ||
[Unreleased]: https://github.com/Esri/esri-leaflet-geocoder/compare/v2.1.1...HEAD | ||
[Unreleased]: https://github.com/Esri/esri-leaflet-geocoder/compare/v2.1.2...HEAD | ||
[2.1.2]: https://github.com/Esri/esri-leaflet-geocoder/compare/v2.1.1...v2.1.2 | ||
[2.1.1]: https://github.com/Esri/esri-leaflet-geocoder/compare/v2.1.0...v2.1.1 | ||
@@ -213,0 +225,0 @@ [2.1.0]: https://github.com/Esri/esri-leaflet-geocoder/compare/v2.0.3...v2.1.0 |
@@ -1,5 +0,5 @@ | ||
/* esri-leaflet-geocoder - v2.1.1 - Mon Jul 25 2016 15:14:39 GMT-0700 (PDT) | ||
/* esri-leaflet-geocoder - v2.1.2 - Thu Sep 15 2016 15:44:02 GMT-0700 (PDT) | ||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("leaflet"),require("esri-leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet","esri-leaflet"],t):t((e.L=e.L||{},e.L.esri=e.L.esri||{},e.L.esri.Geocoding=e.L.esri.Geocoding||{}),e.L,e.L.esri)}(this,function(e,t,s){"use strict";function i(e){return new g(e)}function o(e){return new f(e)}function n(e){return new v(e)}function r(e){return new m(e)}function a(e,t){return new _(e,t)}function l(e){return new y(e)}function u(e){return new b(e)}function d(e){return new x(e)}function h(e){return new C(e)}function c(e){return new S(e)}t="default"in t?t.default:t;var p="2.1.1",g=s.Task.extend({path:"find",params:{outSr:4326,forStorage:!1,outFields:"*",maxLocations:20},setters:{address:"address",neighborhood:"neighborhood",city:"city",subregion:"subregion",region:"region",postal:"postal",country:"country",text:"text",category:"category",token:"token",key:"magicKey",fields:"outFields",forStorage:"forStorage",maxLocations:"maxLocations"},initialize:function(e){e=e||{},e.url=e.url||L,s.Task.prototype.initialize.call(this,e)},within:function(e){return e=t.latLngBounds(e),this.params.bbox=s.Util.boundsToExtent(e),this},nearby:function(e,s){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this.params.distance=Math.min(Math.max(s,2e3),5e4),this},run:function(e,t){return this.options.customParam?(this.path="findAddressCandidates",this.params[this.options.customParam]=this.params.text,delete this.params.text):this.path=this.params.text?"find":"findAddressCandidates","findAddressCandidates"===this.path&&this.params.bbox&&(this.params.searchExtent=this.params.bbox,delete this.params.bbox),this.request(function(s,i){var o="find"===this.path?this._processFindResponse:this._processFindAddressCandidatesResponse,n=s?void 0:o(i);e.call(t,s,{results:n},i)},this)},_processFindResponse:function(e){for(var i=[],o=0;o<e.locations.length;o++){var n,r=e.locations[o];r.extent&&(n=s.Util.extentToBounds(r.extent)),i.push({text:r.name,bounds:n,score:r.feature.attributes.Score,latlng:t.latLng(r.feature.geometry.y,r.feature.geometry.x),properties:r.feature.attributes})}return i},_processFindAddressCandidatesResponse:function(e){for(var i=[],o=0;o<e.candidates.length;o++){var n=e.candidates[o];if(n.extent)var r=s.Util.extentToBounds(n.extent);i.push({text:n.address,bounds:r,score:n.score,latlng:t.latLng(n.location.y,n.location.x),properties:n.attributes})}return i}}),f=s.Task.extend({path:"reverseGeocode",params:{outSR:4326,returnIntersection:!1},setters:{distance:"distance",language:"langCode",intersection:"returnIntersection"},initialize:function(e){e=e||{},e.url=e.url||L,s.Task.prototype.initialize.call(this,e)},latlng:function(e){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this},run:function(e,s){return this.request(function(i,o){var n;n=i?void 0:{latlng:t.latLng(o.location.y,o.location.x),address:o.address},e.call(s,i,n,o)},this)}}),v=s.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category",countries:"countryCode",maxSuggestions:"maxSuggestions"},initialize:function(e){e=e||{},e.url||(e.url=L,e.supportsSuggest=!0),s.Task.prototype.initialize.call(this,e)},within:function(e){e=t.latLngBounds(e),e=e.pad(.5);var i=e.getCenter(),o=e.getNorthWest();return this.params.location=i.lng+","+i.lat,this.params.distance=Math.min(Math.max(i.distanceTo(o),2e3),5e4),this.params.searchExtent=s.Util.boundsToExtent(e),this},nearby:function(e,s){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this.params.distance=Math.min(Math.max(s,2e3),5e4),this},run:function(e,t){return this.options.supportsSuggest?this.request(function(s,i){e.call(t,s,i,i)},this):void console.warn("this geocoding service does not support asking for suggestions")}}),m=s.Service.extend({initialize:function(e){e=e||{},e.url?(s.Service.prototype.initialize.call(this,e),this._confirmSuggestSupport()):(e.url=L,e.supportsSuggest=!0,s.Service.prototype.initialize.call(this,e))},geocode:function(){return i(this)},reverse:function(){return o(this)},suggest:function(){return n(this)},_confirmSuggestSupport:function(){this.metadata(function(e,t){e||(t.capabilities?t.capabilities.indexOf("Suggest")>-1?this.options.supportsSuggest=!0:this.options.supportsSuggest=!1:(this.options.supportsSuggest=!1,this.options.customParam=t.singleLineAddressField.name))},this)}}),_=t.Evented.extend({options:{zoomToResult:!0,useMapBounds:12,searchBounds:null},initialize:function(e,s){if(t.Util.setOptions(this,s),this._control=e,!s||!s.providers||!s.providers.length)throw new Error("You must specify at least one provider");this._providers=s.providers},_geocode:function(e,s,i){var o,n=0,r=[],a=t.Util.bind(function(t,s){n--,t||(s&&(r=r.concat(s)),n<=0&&(o=this._boundsFromResults(r),this.fire("results",{results:r,bounds:o,latlng:o?o.getCenter():void 0,text:e},!0),this.options.zoomToResult&&o&&this._control._map.fitBounds(o),this.fire("load")))},this);if(s)n++,i.results(e,s,this._searchBounds(),a);else for(var l=0;l<this._providers.length;l++)n++,this._providers[l].results(e,s,this._searchBounds(),a)},_suggest:function(e){var s=this._providers.length,i=t.Util.bind(function(e,i){return t.Util.bind(function(t,o){if(!t){var n;if(s-=1,e.length<2)return this._suggestions.innerHTML="",void(this._suggestions.style.display="none");if(o)for(n=0;n<o.length;n++)o[n].provider=i;if(i._lastRender!==e&&i.nodes){for(n=0;n<i.nodes.length;n++)i.nodes[n].parentElement&&this._control._suggestions.removeChild(i.nodes[n]);i.nodes=[]}o.length&&this._control._input.value===e&&(this._control.clearSuggestions(i.nodes),i._lastRender=e,i.nodes=this._control._renderSuggestions(o),this._control._nodes=[])}},this)},this);this._pendingSuggestions=[];for(var o=0;o<this._providers.length;o++){var n=this._providers[o],r=n.suggestions(e,this._searchBounds(),i(e,n));this._pendingSuggestions.push(r)}},_searchBounds:function(){return null!==this.options.searchBounds?this.options.searchBounds:this.options.useMapBounds===!1?null:this.options.useMapBounds===!0?this._control._map.getBounds():this.options.useMapBounds<=this._control._map.getZoom()?this._control._map.getBounds():null},_boundsFromResults:function(e){if(e.length){for(var s=t.latLngBounds([0,0],[0,0]),i=[],o=[],n=e.length-1;n>=0;n--){var r=e[n];o.push(r.latlng),r.bounds&&r.bounds.isValid()&&!r.bounds.equals(s)&&i.push(r.bounds)}for(var a=t.latLngBounds(o),l=0;l<i.length;l++)a.extend(i[l]);return a}},_getAttribution:function(){for(var e=[],t=this._providers,s=0;s<t.length;s++)t[s].options.attribution&&e.push(t[s].options.attribution);return e.join(", ")}}),y=t.Control.extend({includes:t.Mixin.Events,options:{position:"topleft",collapseAfterResult:!0,expanded:!1,allowMultipleResults:!0,placeholder:"Search for places or addresses",title:"Location Search"},initialize:function(e){if(t.Util.setOptions(this,e),!e||!e.providers||!e.providers.length)throw new Error("You must specify at least one provider");this._geosearchCore=a(this,e),this._geosearchCore._providers=e.providers,this._geosearchCore.addEventParent(this);for(var s=0;s<this._geosearchCore._providers.length;s++)this._geosearchCore._providers[s].addEventParent(this);this._geosearchCore._pendingSuggestions=[],t.Control.prototype.initialize.call(e)},_renderSuggestions:function(e){var s;this._suggestions.style.display="block",this._suggestions.style.maxHeight=this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10+"px";for(var i,o,n=[],r=0;r<e.length;r++){var a=e[r];!o&&this._geosearchCore._providers.length>1&&s!==a.provider.options.label&&(o=t.DomUtil.create("span","geocoder-control-header",this._suggestions),o.textContent=a.provider.options.label,o.innerText=a.provider.options.label,s=a.provider.options.label,n.push(o)),i||(i=t.DomUtil.create("ul","geocoder-control-list",this._suggestions));var l=t.DomUtil.create("li","geocoder-control-suggestion",i);l.innerHTML=a.text,l.provider=a.provider,l["data-magic-key"]=a.magicKey}return t.DomUtil.removeClass(this._input,"geocoder-control-loading"),n.push(i),n},_boundsFromResults:function(e){if(e.length){for(var s=t.latLngBounds([0,0],[0,0]),i=[],o=[],n=e.length-1;n>=0;n--){var r=e[n];o.push(r.latlng),r.bounds&&r.bounds.isValid()&&!r.bounds.equals(s)&&i.push(r.bounds)}for(var a=t.latLngBounds(o),l=0;l<i.length;l++)a.extend(i[l]);return a}},clear:function(){this._suggestions.innerHTML="",this._suggestions.style.display="none",this._input.value="",this.options.collapseAfterResult&&(this._input.placeholder="",t.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")),!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom&&this._map.scrollWheelZoom.enable()},clearSuggestions:function(){if(this._nodes)for(var e=0;e<this._nodes.length;e++)this._nodes[e].parentElement&&this._suggestions.removeChild(this._nodes[e])},_setupClick:function(){t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded"),this._input.focus()},disable:function(){this._input.disabled=!0,t.DomUtil.addClass(this._input,"geocoder-control-input-disabled"),t.DomEvent.removeListener(this._wrapper,"click",this._setupClick,this)},enable:function(){this._input.disabled=!1,t.DomUtil.removeClass(this._input,"geocoder-control-input-disabled"),t.DomEvent.addListener(this._wrapper,"click",this._setupClick,this)},getAttribution:function(){for(var e=[],t=0;t<this._providers.length;t++)this._providers[t].options.attribution&&e.push(this._providers[t].options.attribution);return e.join(", ")},onAdd:function(e){this._map=e,this._wrapper=t.DomUtil.create("div","geocoder-control "+(this.options.expanded?" geocoder-control-expanded":"")),this._input=t.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper),this._input.title=this.options.title,this._suggestions=t.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper);var s=this._geosearchCore._getAttribution();return e.attributionControl.addAttribution(s),t.DomEvent.addListener(this._input,"focus",function(e){this._input.placeholder=this.options.placeholder,t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this),t.DomEvent.addListener(this._wrapper,"click",this._setupClick,this),t.DomEvent.addListener(this._suggestions,"mousedown",function(e){var t=e.target||e.srcElement;this._geosearchCore._geocode(t.innerHTML,t["data-magic-key"],t.provider),this.clear()},this),t.DomEvent.addListener(this._input,"blur",function(e){this.clear()},this),t.DomEvent.addListener(this._input,"keydown",function(e){t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");for(var s,i=this._suggestions.querySelectorAll(".geocoder-control-suggestion"),o=this._suggestions.querySelectorAll(".geocoder-control-selected")[0],n=0;n<i.length;n++)if(i[n]===o){s=n;break}switch(e.keyCode){case 13:o?(this._geosearchCore._geocode(o.innerHTML,o["data-magic-key"],o.provider),this.clear()):this.options.allowMultipleResults?(this._geosearchCore._geocode(this._input.value,void 0),this.clear()):t.DomUtil.addClass(i[0],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;case 38:o&&t.DomUtil.removeClass(o,"geocoder-control-selected");var r=i[s-1];o&&r?t.DomUtil.addClass(r,"geocoder-control-selected"):t.DomUtil.addClass(i[i.length-1],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;case 40:o&&t.DomUtil.removeClass(o,"geocoder-control-selected");var a=i[s+1];o&&a?t.DomUtil.addClass(a,"geocoder-control-selected"):t.DomUtil.addClass(i[0],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;default:for(var l=0;l<this._geosearchCore._pendingSuggestions.length;l++){var u=this._geosearchCore._pendingSuggestions[l];u&&u.abort&&!u.id&&u.abort()}}},this),t.DomEvent.addListener(this._input,"keyup",t.Util.throttle(function(e){var s=e.which||e.keyCode,i=(e.target||e.srcElement).value;return i.length<2?(this._suggestions.innerHTML="",this._suggestions.style.display="none",void t.DomUtil.removeClass(this._input,"geocoder-control-loading")):27===s?(this._suggestions.innerHTML="",void(this._suggestions.style.display="none")):void(13!==s&&38!==s&&40!==s&&this._input.value!==this._lastValue&&(this._lastValue=this._input.value,t.DomUtil.addClass(this._input,"geocoder-control-loading"),this._geosearchCore._suggest(i)))},50,this),this),t.DomEvent.disableClickPropagation(this._wrapper),t.DomEvent.addListener(this._suggestions,"mouseover",function(t){e.scrollWheelZoom.enabled()&&e.options.scrollWheelZoom&&e.scrollWheelZoom.disable()}),t.DomEvent.addListener(this._suggestions,"mouseout",function(t){!e.scrollWheelZoom.enabled()&&e.options.scrollWheelZoom&&e.scrollWheelZoom.enable()}),this._geosearchCore.on("load",function(e){t.DomUtil.removeClass(this._input,"geocoder-control-loading"),this.clear(),this._input.blur()},this),this._wrapper},onRemove:function(e){e.attributionControl.removeAttribution("Geocoding by Esri")}}),b=m.extend({options:{label:"Places and Addresses",maxResults:5,attribution:'<a href="https://developers.arcgis.com/en/features/geocoding/">Geocoding by Esri</a>'},suggestions:function(e,t,s){var i=this.suggest().text(e);return t&&i.within(t),this.options.countries&&i.countries(this.options.countries),this.options.categories&&i.category(this.options.categories),i.maxSuggestions(this.options.maxResults),i.run(function(e,t,i){var o=[];if(!e)for(;i.suggestions.length&&o.length<=this.options.maxResults-1;){var n=i.suggestions.shift();n.isCollection||o.push({text:n.text,magicKey:n.magicKey})}s(e,o)},this)},results:function(e,t,s,i){var o=this.geocode().text(e);return t&&o.key(t),o.maxLocations(this.options.maxResults),s&&o.within(s),this.options.forStorage&&o.forStorage(!0),o.run(function(e,t){i(e,t.results)},this)}}),x=s.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1e3,formatSuggestion:function(e){return e.properties[this.options.searchFields[0]]}},initialize:function(e){s.FeatureLayerService.prototype.initialize.call(this,e),"string"==typeof this.options.searchFields&&(this.options.searchFields=[this.options.searchFields])},suggestions:function(e,t,s){var i=this.query().where(this._buildQuery(e)).returnGeometry(!1);t&&i.intersects(t),this.options.idField&&i.fields([this.options.idField].concat(this.options.searchFields));var o=i.run(function(e,t,i){if(e)s(e,[]);else{this.options.idField=i.objectIdFieldName;for(var o=[],n=Math.min(t.features.length,this.options.maxResults),r=0;r<n;r++){var a=t.features[r];o.push({text:this.options.formatSuggestion.call(this,a),magicKey:a.id})}s(e,o.slice(0,this.options.maxResults).reverse())}},this);return o},results:function(e,s,i,o){var n=this.query();return s?n.featureIds([s]):n.where(this._buildQuery(e)),i&&n.within(i),n.run(t.Util.bind(function(e,t){for(var s=[],i=0;i<t.features.length;i++){var n=t.features[i];if(n){var r=this._featureBounds(n),a={latlng:r.getCenter(),bounds:r,text:this.options.formatSuggestion.call(this,n),properties:n.properties,geojson:n};s.push(a)}}o(e,s)},this))},_buildQuery:function(e){for(var t=[],s=this.options.searchFields.length-1;s>=0;s--){var i='upper("'+this.options.searchFields[s]+'")';t.push(i+" LIKE upper('%"+e+"%')")}return t.join(" OR ")},_featureBounds:function(e){var s=t.geoJson(e);if("Point"===e.geometry.type){var i=s.getBounds().getCenter(),o=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*i.lat),n=this.options.bufferRadius/40075017*360;return t.latLngBounds([i.lat-n,i.lng-o],[i.lat+n,i.lng+o])}return s.getBounds()}}),C=s.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(e){return e.properties[e.displayFieldName]+" <small>"+e.layerName+"</small>"}},initialize:function(e){s.MapService.prototype.initialize.call(this,e),this._getIdFields()},suggestions:function(e,t,s){var i=this.find().text(e).fields(this.options.searchFields).returnGeometry(!1).layers(this.options.layers);return i.run(function(e,t,i){var o=[];if(!e){var n=Math.min(this.options.maxResults,t.features.length);i.results=i.results.reverse();for(var r=0;r<n;r++){var a=t.features[r],l=i.results[r],u=l.layerId,d=this._idFields[u];a.layerId=u,a.layerName=this._layerNames[u],a.displayFieldName=this._displayFields[u],d&&o.push({text:this.options.formatSuggestion.call(this,a),magicKey:l.attributes[d]+":"+u})}}s(e,o.reverse())},this)},results:function(e,t,s,i){var o,n=[];if(t){var r=t.split(":")[0],a=t.split(":")[1];o=this.query().layer(a).featureIds(r)}else o=this.find().text(e).fields(this.options.searchFields).contains(!1).layers(this.options.layers);return o.run(function(e,t,s){if(!e){s.results&&(s.results=s.results.reverse());for(var o=0;o<t.features.length;o++){var r=t.features[o];if(a=a||s.results[o].layerId,r&&void 0!==a){var l=this._featureBounds(r);r.layerId=a,r.layerName=this._layerNames[a],r.displayFieldName=this._displayFields[a];var u={latlng:l.getCenter(),bounds:l,text:this.options.formatSuggestion.call(this,r),properties:r.properties,geojson:r};n.push(u)}}}i(e,n.reverse())},this)},_featureBounds:function(e){var s=t.geoJson(e);if("Point"===e.geometry.type){var i=s.getBounds().getCenter(),o=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*i.lat),n=this.options.bufferRadius/40075017*360;return t.latLngBounds([i.lat-n,i.lng-o],[i.lat+n,i.lng+o])}return s.getBounds()},_layerMetadataCallback:function(e){return t.Util.bind(function(t,s){if(!t){this._displayFields[e]=s.displayField,this._layerNames[e]=s.name;for(var i=0;i<s.fields.length;i++){var o=s.fields[i];if("esriFieldTypeOID"===o.type){this._idFields[e]=o.name;break}}}},this)},_getIdFields:function(){this._idFields={},this._displayFields={},this._layerNames={};for(var e=0;e<this.options.layers.length;e++){var t=this.options.layers[e];this.get(t,{},this._layerMetadataCallback(t))}}}),S=m.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(e,t,s){if(this.options.supportsSuggest){var i=this.suggest().text(e);return t&&i.within(t),i.run(function(e,t,i){var o=[];if(!e)for(;i.suggestions.length&&o.length<=this.options.maxResults-1;){var n=i.suggestions.shift();n.isCollection||o.push({text:n.text,magicKey:n.magicKey})}s(e,o)},this)}return s(void 0,[]),!1},results:function(e,t,s,i){var o=this.geocode().text(e);return o.maxLocations(this.options.maxResults),s&&o.within(s),o.run(function(e,t){i(e,t.results)},this)}}),L="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";e.WorldGeocodingServiceUrl=L,e.VERSION=p,e.Geocode=g,e.geocode=i,e.ReverseGeocode=f,e.reverseGeocode=o,e.Suggest=v,e.suggest=n,e.GeocodeService=m,e.geocodeService=r,e.Geosearch=y,e.geosearch=l,e.GeosearchCore=_,e.geosearchCore=a,e.ArcgisOnlineProvider=b,e.arcgisOnlineProvider=u,e.FeatureLayerProvider=x,e.featureLayerProvider=d,e.MapServiceProvider=C,e.mapServiceProvider=h,e.GeocodeServiceProvider=S,e.geocodeServiceProvider=c}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("leaflet"),require("esri-leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet","esri-leaflet"],t):t((e.L=e.L||{},e.L.esri=e.L.esri||{},e.L.esri.Geocoding=e.L.esri.Geocoding||{}),e.L,e.L.esri)}(this,function(e,t,s){"use strict";function i(e){return new g(e)}function o(e){return new f(e)}function n(e){return new v(e)}function r(e){return new m(e)}function a(e,t){return new _(e,t)}function l(e){return new y(e)}function u(e){return new b(e)}function d(e){return new x(e)}function h(e){return new C(e)}function c(e){return new S(e)}t="default"in t?t["default"]:t;var p="2.1.2",g=s.Task.extend({path:"find",params:{outSr:4326,forStorage:!1,outFields:"*",maxLocations:20},setters:{address:"address",neighborhood:"neighborhood",city:"city",subregion:"subregion",region:"region",postal:"postal",country:"country",text:"text",category:"category",token:"token",key:"magicKey",fields:"outFields",forStorage:"forStorage",maxLocations:"maxLocations"},initialize:function(e){e=e||{},e.url=e.url||L,s.Task.prototype.initialize.call(this,e)},within:function(e){return e=t.latLngBounds(e),this.params.bbox=s.Util.boundsToExtent(e),this},nearby:function(e,s){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this.params.distance=Math.min(Math.max(s,2e3),5e4),this},run:function(e,t){return this.options.customParam?(this.path="findAddressCandidates",this.params[this.options.customParam]=this.params.text,delete this.params.text):this.path=this.params.text?"find":"findAddressCandidates","findAddressCandidates"===this.path&&this.params.bbox&&(this.params.searchExtent=this.params.bbox,delete this.params.bbox),this.request(function(s,i){var o="find"===this.path?this._processFindResponse:this._processFindAddressCandidatesResponse,n=s?void 0:o(i);e.call(t,s,{results:n},i)},this)},_processFindResponse:function(e){for(var i=[],o=0;o<e.locations.length;o++){var n,r=e.locations[o];r.extent&&(n=s.Util.extentToBounds(r.extent)),i.push({text:r.name,bounds:n,score:r.feature.attributes.Score,latlng:t.latLng(r.feature.geometry.y,r.feature.geometry.x),properties:r.feature.attributes})}return i},_processFindAddressCandidatesResponse:function(e){for(var i=[],o=0;o<e.candidates.length;o++){var n=e.candidates[o];if(n.extent)var r=s.Util.extentToBounds(n.extent);i.push({text:n.address,bounds:r,score:n.score,latlng:t.latLng(n.location.y,n.location.x),properties:n.attributes})}return i}}),f=s.Task.extend({path:"reverseGeocode",params:{outSR:4326,returnIntersection:!1},setters:{distance:"distance",language:"langCode",intersection:"returnIntersection"},initialize:function(e){e=e||{},e.url=e.url||L,s.Task.prototype.initialize.call(this,e)},latlng:function(e){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this},run:function(e,s){return this.request(function(i,o){var n;n=i?void 0:{latlng:t.latLng(o.location.y,o.location.x),address:o.address},e.call(s,i,n,o)},this)}}),v=s.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category",countries:"countryCode",maxSuggestions:"maxSuggestions"},initialize:function(e){e=e||{},e.url||(e.url=L,e.supportsSuggest=!0),s.Task.prototype.initialize.call(this,e)},within:function(e){e=t.latLngBounds(e),e=e.pad(.5);var i=e.getCenter(),o=e.getNorthWest();return this.params.location=i.lng+","+i.lat,this.params.distance=Math.min(Math.max(i.distanceTo(o),2e3),5e4),this.params.searchExtent=s.Util.boundsToExtent(e),this},nearby:function(e,s){return e=t.latLng(e),this.params.location=e.lng+","+e.lat,this.params.distance=Math.min(Math.max(s,2e3),5e4),this},run:function(e,t){return this.options.supportsSuggest?this.request(function(s,i){e.call(t,s,i,i)},this):void console.warn("this geocoding service does not support asking for suggestions")}}),m=s.Service.extend({initialize:function(e){e=e||{},e.url?(s.Service.prototype.initialize.call(this,e),this._confirmSuggestSupport()):(e.url=L,e.supportsSuggest=!0,s.Service.prototype.initialize.call(this,e))},geocode:function(){return i(this)},reverse:function(){return o(this)},suggest:function(){return n(this)},_confirmSuggestSupport:function(){this.metadata(function(e,t){e||(t.capabilities?t.capabilities.indexOf("Suggest")>-1?this.options.supportsSuggest=!0:this.options.supportsSuggest=!1:(this.options.supportsSuggest=!1,this.options.customParam=t.singleLineAddressField.name))},this)}}),_=t.Evented.extend({options:{zoomToResult:!0,useMapBounds:12,searchBounds:null},initialize:function(e,s){if(t.Util.setOptions(this,s),this._control=e,!s||!s.providers||!s.providers.length)throw new Error("You must specify at least one provider");this._providers=s.providers},_geocode:function(e,s,i){var o,n=0,r=[],a=t.Util.bind(function(t,s){n--,t||(s&&(r=r.concat(s)),0>=n&&(o=this._boundsFromResults(r),this.fire("results",{results:r,bounds:o,latlng:o?o.getCenter():void 0,text:e},!0),this.options.zoomToResult&&o&&this._control._map.fitBounds(o),this.fire("load")))},this);if(s)n++,i.results(e,s,this._searchBounds(),a);else for(var l=0;l<this._providers.length;l++)n++,this._providers[l].results(e,s,this._searchBounds(),a)},_suggest:function(e){var s=this._providers.length,i=t.Util.bind(function(e,i){return t.Util.bind(function(t,o){if(!t){var n;if(s-=1,e.length<2)return this._suggestions.innerHTML="",void(this._suggestions.style.display="none");if(o)for(n=0;n<o.length;n++)o[n].provider=i;if(i._lastRender!==e&&i.nodes){for(n=0;n<i.nodes.length;n++)i.nodes[n].parentElement&&this._control._suggestions.removeChild(i.nodes[n]);i.nodes=[]}o.length&&this._control._input.value===e&&(this._control.clearSuggestions(i.nodes),i._lastRender=e,i.nodes=this._control._renderSuggestions(o),this._control._nodes=[])}},this)},this);this._pendingSuggestions=[];for(var o=0;o<this._providers.length;o++){var n=this._providers[o],r=n.suggestions(e,this._searchBounds(),i(e,n));this._pendingSuggestions.push(r)}},_searchBounds:function(){return null!==this.options.searchBounds?this.options.searchBounds:this.options.useMapBounds===!1?null:this.options.useMapBounds===!0?this._control._map.getBounds():this.options.useMapBounds<=this._control._map.getZoom()?this._control._map.getBounds():null},_boundsFromResults:function(e){if(e.length){for(var s=t.latLngBounds([0,0],[0,0]),i=[],o=[],n=e.length-1;n>=0;n--){var r=e[n];o.push(r.latlng),r.bounds&&r.bounds.isValid()&&!r.bounds.equals(s)&&i.push(r.bounds)}for(var a=t.latLngBounds(o),l=0;l<i.length;l++)a.extend(i[l]);return a}},_getAttribution:function(){for(var e=[],t=this._providers,s=0;s<t.length;s++)t[s].options.attribution&&e.push(t[s].options.attribution);return e.join(", ")}}),y=m.extend({options:{label:"Places and Addresses",maxResults:5},suggestions:function(e,t,s){var i=this.suggest().text(e);return t&&i.within(t),this.options.countries&&i.countries(this.options.countries),this.options.categories&&i.category(this.options.categories),i.maxSuggestions(this.options.maxResults),i.run(function(e,t,i){var o=[];if(!e)for(;i.suggestions.length&&o.length<=this.options.maxResults-1;){var n=i.suggestions.shift();n.isCollection||o.push({text:n.text,magicKey:n.magicKey})}s(e,o)},this)},results:function(e,t,s,i){var o=this.geocode().text(e);return t&&o.key(t),o.maxLocations(this.options.maxResults),s&&o.within(s),this.options.forStorage&&o.forStorage(!0),o.run(function(e,t){i(e,t.results)},this)}}),b=t.Control.extend({includes:t.Mixin.Events,options:{position:"topleft",collapseAfterResult:!0,expanded:!1,allowMultipleResults:!0,placeholder:"Search for places or addresses",title:"Location Search"},initialize:function(e){t.Util.setOptions(this,e),e&&e.providers&&e.providers.length||(e={},e.providers=[l()]),this._geosearchCore=a(this,e),this._geosearchCore._providers=e.providers,this._geosearchCore.addEventParent(this);for(var s=0;s<this._geosearchCore._providers.length;s++)this._geosearchCore._providers[s].addEventParent(this);this._geosearchCore._pendingSuggestions=[],t.Control.prototype.initialize.call(e)},_renderSuggestions:function(e){var s;this._suggestions.style.display="block",this._suggestions.style.maxHeight=this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10+"px";for(var i,o,n=[],r=0;r<e.length;r++){var a=e[r];!o&&this._geosearchCore._providers.length>1&&s!==a.provider.options.label&&(o=t.DomUtil.create("span","geocoder-control-header",this._suggestions),o.textContent=a.provider.options.label,o.innerText=a.provider.options.label,s=a.provider.options.label,n.push(o)),i||(i=t.DomUtil.create("ul","geocoder-control-list",this._suggestions));var l=t.DomUtil.create("li","geocoder-control-suggestion",i);l.innerHTML=a.text,l.provider=a.provider,l["data-magic-key"]=a.magicKey}return t.DomUtil.removeClass(this._input,"geocoder-control-loading"),n.push(i),n},_boundsFromResults:function(e){if(e.length){for(var s=t.latLngBounds([0,0],[0,0]),i=[],o=[],n=e.length-1;n>=0;n--){var r=e[n];o.push(r.latlng),r.bounds&&r.bounds.isValid()&&!r.bounds.equals(s)&&i.push(r.bounds)}for(var a=t.latLngBounds(o),l=0;l<i.length;l++)a.extend(i[l]);return a}},clear:function(){this._suggestions.innerHTML="",this._suggestions.style.display="none",this._input.value="",this.options.collapseAfterResult&&(this._input.placeholder="",t.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")),!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom&&this._map.scrollWheelZoom.enable()},clearSuggestions:function(){if(this._nodes)for(var e=0;e<this._nodes.length;e++)this._nodes[e].parentElement&&this._suggestions.removeChild(this._nodes[e])},_setupClick:function(){t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded"),this._input.focus()},disable:function(){this._input.disabled=!0,t.DomUtil.addClass(this._input,"geocoder-control-input-disabled"),t.DomEvent.removeListener(this._wrapper,"click",this._setupClick,this)},enable:function(){this._input.disabled=!1,t.DomUtil.removeClass(this._input,"geocoder-control-input-disabled"),t.DomEvent.addListener(this._wrapper,"click",this._setupClick,this)},getAttribution:function(){for(var e=[],t=0;t<this._providers.length;t++)this._providers[t].options.attribution&&e.push(this._providers[t].options.attribution);return e.join(", ")},onAdd:function(e){s.Util.setEsriAttribution(e),this._map=e,this._wrapper=t.DomUtil.create("div","geocoder-control "+(this.options.expanded?" geocoder-control-expanded":"")),this._input=t.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper),this._input.title=this.options.title,this._suggestions=t.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper);var i=this._geosearchCore._getAttribution();return e.attributionControl.addAttribution(i),t.DomEvent.addListener(this._input,"focus",function(e){this._input.placeholder=this.options.placeholder,t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this),t.DomEvent.addListener(this._wrapper,"click",this._setupClick,this),t.DomEvent.addListener(this._suggestions,"mousedown",function(e){var t=e.target||e.srcElement;this._geosearchCore._geocode(t.innerHTML,t["data-magic-key"],t.provider),this.clear()},this),t.DomEvent.addListener(this._input,"blur",function(e){this.clear()},this),t.DomEvent.addListener(this._input,"keydown",function(e){t.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");for(var s,i=this._suggestions.querySelectorAll(".geocoder-control-suggestion"),o=this._suggestions.querySelectorAll(".geocoder-control-selected")[0],n=0;n<i.length;n++)if(i[n]===o){s=n;break}switch(e.keyCode){case 13:o?(this._geosearchCore._geocode(o.innerHTML,o["data-magic-key"],o.provider),this.clear()):this.options.allowMultipleResults?(this._geosearchCore._geocode(this._input.value,void 0),this.clear()):t.DomUtil.addClass(i[0],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;case 38:o&&t.DomUtil.removeClass(o,"geocoder-control-selected");var r=i[s-1];o&&r?t.DomUtil.addClass(r,"geocoder-control-selected"):t.DomUtil.addClass(i[i.length-1],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;case 40:o&&t.DomUtil.removeClass(o,"geocoder-control-selected");var a=i[s+1];o&&a?t.DomUtil.addClass(a,"geocoder-control-selected"):t.DomUtil.addClass(i[0],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;default:for(var l=0;l<this._geosearchCore._pendingSuggestions.length;l++){var u=this._geosearchCore._pendingSuggestions[l];u&&u.abort&&!u.id&&u.abort()}}},this),t.DomEvent.addListener(this._input,"keyup",t.Util.throttle(function(e){var s=e.which||e.keyCode,i=(e.target||e.srcElement).value;return i.length<2?(this._suggestions.innerHTML="",this._suggestions.style.display="none",void t.DomUtil.removeClass(this._input,"geocoder-control-loading")):27===s?(this._suggestions.innerHTML="",void(this._suggestions.style.display="none")):void(13!==s&&38!==s&&40!==s&&this._input.value!==this._lastValue&&(this._lastValue=this._input.value,t.DomUtil.addClass(this._input,"geocoder-control-loading"),this._geosearchCore._suggest(i)))},50,this),this),t.DomEvent.disableClickPropagation(this._wrapper),t.DomEvent.addListener(this._suggestions,"mouseover",function(t){e.scrollWheelZoom.enabled()&&e.options.scrollWheelZoom&&e.scrollWheelZoom.disable()}),t.DomEvent.addListener(this._suggestions,"mouseout",function(t){!e.scrollWheelZoom.enabled()&&e.options.scrollWheelZoom&&e.scrollWheelZoom.enable()}),this._geosearchCore.on("load",function(e){t.DomUtil.removeClass(this._input,"geocoder-control-loading"),this.clear(),this._input.blur()},this),this._wrapper},onRemove:function(e){e.attributionControl.removeAttribution("Geocoding by Esri")}}),x=s.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1e3,formatSuggestion:function(e){return e.properties[this.options.searchFields[0]]}},initialize:function(e){s.FeatureLayerService.prototype.initialize.call(this,e),"string"==typeof this.options.searchFields&&(this.options.searchFields=[this.options.searchFields])},suggestions:function(e,t,s){var i=this.query().where(this._buildQuery(e)).returnGeometry(!1);t&&i.intersects(t),this.options.idField&&i.fields([this.options.idField].concat(this.options.searchFields));var o=i.run(function(e,t,i){if(e)s(e,[]);else{this.options.idField=i.objectIdFieldName;for(var o=[],n=Math.min(t.features.length,this.options.maxResults),r=0;n>r;r++){var a=t.features[r];o.push({text:this.options.formatSuggestion.call(this,a),magicKey:a.id})}s(e,o.slice(0,this.options.maxResults).reverse())}},this);return o},results:function(e,s,i,o){var n=this.query();return s?n.featureIds([s]):n.where(this._buildQuery(e)),i&&n.within(i),n.run(t.Util.bind(function(e,t){for(var s=[],i=0;i<t.features.length;i++){var n=t.features[i];if(n){var r=this._featureBounds(n),a={latlng:r.getCenter(),bounds:r,text:this.options.formatSuggestion.call(this,n),properties:n.properties,geojson:n};s.push(a)}}o(e,s)},this))},_buildQuery:function(e){for(var t=[],s=this.options.searchFields.length-1;s>=0;s--){var i='upper("'+this.options.searchFields[s]+'")';t.push(i+" LIKE upper('%"+e+"%')")}return this.options.where?this.options.where+" AND "+t.join(" OR "):t.join(" OR ")},_featureBounds:function(e){var s=t.geoJson(e);if("Point"===e.geometry.type){var i=s.getBounds().getCenter(),o=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*i.lat),n=this.options.bufferRadius/40075017*360;return t.latLngBounds([i.lat-n,i.lng-o],[i.lat+n,i.lng+o])}return s.getBounds()}}),C=s.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(e){return e.properties[e.displayFieldName]+" <small>"+e.layerName+"</small>"}},initialize:function(e){s.MapService.prototype.initialize.call(this,e),this._getIdFields()},suggestions:function(e,t,s){var i=this.find().text(e).fields(this.options.searchFields).returnGeometry(!1).layers(this.options.layers);return i.run(function(e,t,i){var o=[];if(!e){var n=Math.min(this.options.maxResults,t.features.length);i.results=i.results.reverse();for(var r=0;n>r;r++){var a=t.features[r],l=i.results[r],u=l.layerId,d=this._idFields[u];a.layerId=u,a.layerName=this._layerNames[u],a.displayFieldName=this._displayFields[u],d&&o.push({text:this.options.formatSuggestion.call(this,a),magicKey:l.attributes[d]+":"+u})}}s(e,o.reverse())},this)},results:function(e,t,s,i){var o,n=[];if(t){var r=t.split(":")[0],a=t.split(":")[1];o=this.query().layer(a).featureIds(r)}else o=this.find().text(e).fields(this.options.searchFields).contains(!1).layers(this.options.layers);return o.run(function(e,t,s){if(!e){s.results&&(s.results=s.results.reverse());for(var o=0;o<t.features.length;o++){var r=t.features[o];if(a=a||s.results[o].layerId,r&&void 0!==a){var l=this._featureBounds(r);r.layerId=a,r.layerName=this._layerNames[a],r.displayFieldName=this._displayFields[a];var u={latlng:l.getCenter(),bounds:l,text:this.options.formatSuggestion.call(this,r),properties:r.properties,geojson:r};n.push(u)}}}i(e,n.reverse())},this)},_featureBounds:function(e){var s=t.geoJson(e);if("Point"===e.geometry.type){var i=s.getBounds().getCenter(),o=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*i.lat),n=this.options.bufferRadius/40075017*360;return t.latLngBounds([i.lat-n,i.lng-o],[i.lat+n,i.lng+o])}return s.getBounds()},_layerMetadataCallback:function(e){return t.Util.bind(function(t,s){if(!t){this._displayFields[e]=s.displayField,this._layerNames[e]=s.name;for(var i=0;i<s.fields.length;i++){var o=s.fields[i];if("esriFieldTypeOID"===o.type){this._idFields[e]=o.name;break}}}},this)},_getIdFields:function(){this._idFields={},this._displayFields={},this._layerNames={};for(var e=0;e<this.options.layers.length;e++){var t=this.options.layers[e];this.get(t,{},this._layerMetadataCallback(t))}}}),S=m.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(e,t,s){if(this.options.supportsSuggest){var i=this.suggest().text(e);return t&&i.within(t),i.run(function(e,t,i){var o=[];if(!e)for(;i.suggestions.length&&o.length<=this.options.maxResults-1;){var n=i.suggestions.shift();n.isCollection||o.push({text:n.text,magicKey:n.magicKey})}s(e,o)},this)}return s(void 0,[]),!1},results:function(e,t,s,i){var o=this.geocode().text(e);return o.maxLocations(this.options.maxResults),s&&o.within(s),o.run(function(e,t){i(e,t.results)},this)}}),L="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";e.WorldGeocodingServiceUrl=L,e.VERSION=p,e.Geocode=g,e.geocode=i,e.ReverseGeocode=f,e.reverseGeocode=o,e.Suggest=v,e.suggest=n,e.GeocodeService=m,e.geocodeService=r,e.Geosearch=b,e.geosearch=u,e.GeosearchCore=_,e.geosearchCore=a,e.ArcgisOnlineProvider=y,e.arcgisOnlineProvider=l,e.FeatureLayerProvider=x,e.featureLayerProvider=d,e.MapServiceProvider=C,e.mapServiceProvider=h,e.GeocodeServiceProvider=S,e.geocodeServiceProvider=c}); | ||
//# sourceMappingURL=esri-leaflet-geocoder.js.map |
{ | ||
"name": "esri-leaflet-geocoder", | ||
"description": "Esri Geocoding utility and search plugin for Leaflet.", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"author": "Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)", | ||
@@ -11,4 +11,4 @@ "contributors": [ | ||
"dependencies": { | ||
"esri-leaflet": "^2.0.0", | ||
"leaflet": "^1.0.0-rc.1" | ||
"esri-leaflet": "^2.0.3", | ||
"leaflet": "^1.0.0-rc.3" | ||
}, | ||
@@ -67,3 +67,3 @@ "devDependencies": { | ||
"release": "./scripts/release.sh", | ||
"start": "watch 'npm run build' src & http-server -p 5678 -c-1 -o", | ||
"start": "watch \"npm run build\" src | http-server -p 5678 -c-1 -o", | ||
"test": "npm run lint && karma start" | ||
@@ -70,0 +70,0 @@ }, |
@@ -29,10 +29,10 @@ # Esri Leaflet Geocoder | ||
<!-- Load Leaflet from CDN--> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.1/leaflet.css" /> | ||
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.1/leaflet.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.css" /> | ||
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.js"></script> | ||
<!-- Esri Leaflet --> | ||
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.1/esri-leaflet.js"></script> | ||
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.3/esri-leaflet.js"></script> | ||
<!-- Esri Leaflet Geocoder --> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.1/esri-leaflet-geocoder.css"> | ||
<script src="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.1/esri-leaflet-geocoder.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.2/esri-leaflet-geocoder.css"> | ||
<script src="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.2/esri-leaflet-geocoder.js"></script> | ||
<!-- Make the map fill the entire page --> | ||
@@ -54,11 +54,8 @@ <style> | ||
var map = L.map('map').setView([45.5165, -122.6764], 12); | ||
var tiles = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { | ||
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
var tiles = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png").addTo(map); | ||
var arcgisOnline = L.esri.Geocoding.arcgisOnlineProvider(); | ||
// create the geocoding control and add it to the map | ||
var searchControl = L.esri.Geocoding.geosearch({ | ||
providers: [arcgisOnline] | ||
}).addTo(map); | ||
var searchControl = L.esri.Geocoding.geosearch().addTo(map); | ||
@@ -124,15 +121,21 @@ // create an empty layer group to store the results and add it to the map | ||
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing). | ||
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/Esri/esri-leaflet/blob/master/CONTRIBUTING.md). | ||
## Terms and Conditions | ||
In order the use the ArcGIS Online Geocoding Service you should signup for an [ArcGIS for Developers account](https://developers.arcgis.com/en/plans) or purchase an [ArcGIS Online Organizational Subscription](http://www.arcgis.com/features/plans/pricing.html). | ||
In order to make use of the ArcGIS Online World Geocoding Service in your web application: | ||
1. Once you have an account you are good to go. Thats it! | ||
2. Your users can search for as many places as they want. Esri defines this as "Geosearch" and its free. You only consume credits when you want to store the result of geocodes. | ||
3. You are allowed to store the results of any geocoding you do if you pass the `forStorage` flag and a valid access token. | ||
4. If you use this library in a revenue generating application or for government use you must upgrade to a paid account. You are not allowed to generate revenue while on a free plan. | ||
1. Please sign up for an [ArcGIS for Developers account](https://developers.arcgis.com/en/plans) or purchase an [ArcGIS Online Organizational Subscription](http://www.arcgis.com/features/plans/pricing.html). | ||
2. Ensure that `Powered by`[`Esri`](http://esri.com) is displayed in the map attribution. | ||
This information is from the [ArcGIS for Developers Terms of Use FAQ](https://developers.arcgis.com/en/terms/faq/) and the [ArcGIS Online World Geocoder documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Single_input_field_geocoding/02r300000015000000/) | ||
## Cost | ||
1. User search for individual locations within web applications is defined by Esri as *Geosearch* and it is free. [Credits](https://developers.arcgis.com/credits/) are only consumed when you store results permanently. | ||
2. To store geocoding results, pass `forStorage: true` and a valid access token. | ||
3. You are not allowed to generate revenue while on a free ArcGIS Developer plan. | ||
4. If your application might generate more than 1 million searches in a month, please [contact us](http://www.esri.com/about-esri/contact). | ||
* [ArcGIS for Developers Terms of Use FAQ](https://developers.arcgis.com/en/terms/faq/) | ||
* [ArcGIS Online World Geocoder documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Single_input_field_geocoding/02r300000015000000/) | ||
## Licensing | ||
@@ -139,0 +142,0 @@ Copyright 2016 Esri |
import L from 'leaflet'; | ||
import { geosearchCore } from '../Classes/GeosearchCore'; | ||
import { arcgisOnlineProvider } from '../Providers/ArcgisOnlineGeocoder'; | ||
import { Util } from 'esri-leaflet'; | ||
@@ -20,3 +22,4 @@ export var Geosearch = L.Control.extend({ | ||
if (!options || !options.providers || !options.providers.length) { | ||
throw new Error('You must specify at least one provider'); | ||
options = {}; | ||
options.providers = [ arcgisOnlineProvider() ]; | ||
} | ||
@@ -169,2 +172,5 @@ | ||
onAdd: function (map) { | ||
// include 'Powered by Esri' in map attribution | ||
Util.setEsriAttribution(map); | ||
this._map = map; | ||
@@ -171,0 +177,0 @@ this._wrapper = L.DomUtil.create('div', 'geocoder-control ' + ((this.options.expanded) ? ' ' + 'geocoder-control-expanded' : '')); |
@@ -6,4 +6,3 @@ import { GeocodeService } from '../Services/Geocode'; | ||
label: 'Places and Addresses', | ||
maxResults: 5, | ||
attribution: '<a href="https://developers.arcgis.com/en/features/geocoding/">Geocoding by Esri</a>' | ||
maxResults: 5 | ||
}, | ||
@@ -10,0 +9,0 @@ |
@@ -98,3 +98,7 @@ import L from 'leaflet'; | ||
return queryString.join(' OR '); | ||
if (this.options.where) { | ||
return this.options.where + ' AND ' + queryString.join(' OR '); | ||
} else { | ||
return queryString.join(' OR '); | ||
} | ||
}, | ||
@@ -101,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
157
317699
37
2287
Updatedesri-leaflet@^2.0.3
Updatedleaflet@^1.0.0-rc.3