New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esri-leaflet-geocoder

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esri-leaflet-geocoder - npm Package Compare versions

Comparing version 1.0.0-rc.4 to 1.0.0

2

bower.json
{
"name": "esri-leaflet-geocoder",
"version": "v1.0.0-rc.4",
"version": "v1.0.0",
"main": "dist/esri-leaflet-geocoder.js",

@@ -6,0 +6,0 @@ "ignore": [

# Changelog
## 1.0.0
This represents the stable release of Esri Leaflet Geocoder compatible with Leaflet 0.7.3. All future 1.0.X releases will be compatible with Leaflet 0.7.3 and contain only bug fixes. New features will only be added in Esri Leaflet Geocoder 2.0.0 which will require Leaflet 1.0.0.
#### Changes
* Introduced support for dynamic suggestions from custom geocoding services. #65
* Refactored code to account for changes introduced in Esri Leaflet `1.0.0`. #75
* Fixed problem in `initialize` #63 (thanks @timwis!)
* Plugin now dynamically sets a hard search extent when `useMapBounds` is set to true. #58
## Release Candidate 3
#### Breaking Changes
* Providers should now supply their `url` with the `url` key inside of `options` as opposed to a separate parameter.
* Namespace has been reorganized. everything now sits under `L.esri.Geocoding`. So `L.esri.Tasks.Geocode` is now `L.esri.Geocoding.Tasks.Geocode`.
#### Changes
* `MapService` provider now supports being passed an array of layers to search. https://github.com/Esri/esri-leaflet-geocoder/issues/48
* `title` option will now set the title on the input to `'Location Search'` by default. https://github.com/Esri/esri-leaflet-geocoder/pull/51
* When using many providers or when a provider returns lots of results with a high limit, the suggestions div will now scroll. https://github.com/Esri/esri-leaflet-geocoder/issues/55
* `within()` and `nearby()` now return the task and can be changed. https://github.com/Esri/esri-leaflet-geocoder/pull/49
* Bugfix for `MapService` provider https://github.com/Esri/esri-leaflet-geocoder/issues/46
## Release Candidate 2
#### Changes
* Bower support `bower install esri-leaflet-geocoder`
* Update Esri Leaflet dependency to RC 3
## Release Candidate 1

@@ -51,3 +84,3 @@

* Fix bug in IE 10 and 11 on Windows 8 touch devices
## Beta 1

@@ -54,0 +87,0 @@

@@ -1,2 +0,2 @@

/*! esri-leaflet-geocoder - v1.0.0-rc.4 - 2015-01-09
/*! esri-leaflet-geocoder - v1.0.0 - 2015-07-10
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.

@@ -108,3 +108,5 @@ * Apache 2.0 License */

var location = response.locations[i];
var bounds = Esri.Util.extentToBounds(location.extent);
if (location.extent) {
var bounds = Esri.Util.extentToBounds(location.extent);
}

@@ -218,2 +220,3 @@ results.push({

this.params.distance = Math.min(Math.max(center.distanceTo(ne), 2000), 50000);
this.params.searchExtent = L.esri.Util.boundsToExtent(bounds);
return this;

@@ -249,2 +252,3 @@ },

Esri.Services.Service.prototype.initialize.call(this, options);
this._confirmSuggestSupport();
},

@@ -261,7 +265,15 @@

suggest: function(){
if(this.options.url !== EsriLeafletGeocoding.WorldGeocodingService && console && console.warn){
console.warn('Only the ArcGIS Online World Geocoder supports suggestions');
return;
}
// requires either the Esri World Geocoding Service or a 10.3 ArcGIS Server Geocoding Service that supports suggest.
return new EsriLeafletGeocoding.Tasks.Suggest(this);
},
_confirmSuggestSupport: function(){
this.metadata(function(error, response) {
if (response.capabilities.includes('Suggest')) {
this.options.supportsSuggest = true;
}
else {
this.options.supportsSuggest = false;
}
}, this);
}

@@ -287,3 +299,4 @@ });

placeholder: 'Search for places or addresses',
title: 'Location Search'
title: 'Location Search',
mapAttribution: 'Geocoding by Esri'
},

@@ -482,3 +495,3 @@

// make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present
if(result.bounds.isValid() && !result.bounds.equals(nullIsland)){
if(result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)){
bounds.extend(result.bounds);

@@ -512,4 +525,9 @@ }

// Add geocoding attribution to map. Using World Geocode Service requires default attribution.
if (map.attributionControl) {
map.attributionControl.addAttribution('Geocoding by Esri');
if (this.options.useArcgisWorldGeocoder) {
map.attributionControl.addAttribution('Geocoding by Esri');
} else {
map.attributionControl.addAttribution(this.options.mapAttribution);
}
}

@@ -671,2 +689,3 @@

EsriLeafletGeocoding.Controls.Geosearch.Providers.ArcGISOnline = EsriLeafletGeocoding.Services.Geocoding.extend({

@@ -725,3 +744,3 @@ options: {

EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer = L.esri.Services.FeatureLayer.extend({
EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer = L.esri.Services.FeatureLayerService.extend({
options: {

@@ -735,4 +754,5 @@ label: 'Feature Layer',

},
intialize: function(url, options){
L.esri.Services.FeatureLayer.prototype.call(this, url, options);
initialize: function(options){
options.url = L.esri.Util.cleanUrl(options.url);
L.esri.Services.FeatureLayerService.prototype.initialize.call(this, options);
L.Util.setOptions(this, options);

@@ -829,2 +849,3 @@ if(typeof this.options.searchFields === 'string'){

EsriLeafletGeocoding.Controls.Geosearch.Providers.GeocodeService = EsriLeafletGeocoding.Services.Geocoding.extend({

@@ -837,4 +858,30 @@ options: {

suggestions: function(text, bounds, callback){
callback(undefined, []);
return false;
if (this.options.supportsSuggest) {
var request = this.suggest().text(text);
if(bounds){
request.within(bounds);
}
return request.run(function(error, results, response){
var suggestions = [];
if(!error){
while(response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)){
var suggestion = response.suggestions.shift();
if(!suggestion.isCollection){
suggestions.push({
text: suggestion.text,
magicKey: suggestion.magicKey
});
}
}
}
callback(error, suggestions);
}, this);
}
else {
callback(undefined, []);
return false;
}
},

@@ -867,4 +914,4 @@

},
initialize: function(url, options){
L.esri.Services.MapService.prototype.initialize.call(this, url, options);
initialize: function(options){
L.esri.Services.MapService.prototype.initialize.call(this, options);
this._getIdFields();

@@ -871,0 +918,0 @@ },

@@ -1,2 +0,2 @@

/*! esri-leaflet-geocoder - v1.0.0-rc.4 - 2015-01-09
/*! esri-leaflet-geocoder - v1.0.0 - 2015-07-10
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.

@@ -24,3 +24,3 @@ * Apache 2.0 License */

var protocol="https:"===window.location.protocol?"https:":"http:",EsriLeafletGeocoding={WorldGeocodingService:protocol+"//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/",Tasks:{},Services:{},Controls:{}};if("undefined"!=typeof window&&window.L&&window.L.esri&&(window.L.esri.Geocoding=EsriLeafletGeocoding),!Esri)var Esri=window.L.esri;EsriLeafletGeocoding.Tasks.Geocode=Esri.Tasks.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(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},within:function(a){return a=L.latLngBounds(a),this.params.bbox=Esri.Util.boundsToExtent(a),this},nearby:function(a,b){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this.params.distance=Math.min(Math.max(b,2e3),5e4),this},run:function(a,b){return 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(c,d){var e="find"===this.path?this._processFindResponse:this._processFindAddressCandidatesResponse,f=c?void 0:e(d);a.call(b,c,{results:f},d)},this)},_processFindResponse:function(a){for(var b=[],c=0;c<a.locations.length;c++){var d=a.locations[c],e=Esri.Util.extentToBounds(d.extent);b.push({text:d.name,bounds:e,score:d.feature.attributes.Score,latlng:new L.LatLng(d.feature.geometry.y,d.feature.geometry.x),properties:d.feature.attributes})}return b},_processFindAddressCandidatesResponse:function(a){for(var b=[],c=0;c<a.candidates.length;c++){var d=a.candidates[c],e=Esri.Util.extentToBounds(d.extent);b.push({text:d.address,bounds:e,score:d.score,latlng:new L.LatLng(d.location.y,d.location.x),properties:d.attributes})}return b}}),EsriLeafletGeocoding.Tasks.geocode=function(a){return new EsriLeafletGeocoding.Tasks.Geocode(a)},EsriLeafletGeocoding.Tasks.ReverseGeocode=Esri.Tasks.Task.extend({path:"reverseGeocode",params:{outSR:4326},setters:{distance:"distance",language:"language"},initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},latlng:function(a){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this},run:function(a,b){return this.request(function(c,d){var e;e=c?void 0:{latlng:new L.LatLng(d.location.y,d.location.x),address:d.address},a.call(b,c,e,d)},this)}}),EsriLeafletGeocoding.Tasks.reverseGeocode=function(a){return new EsriLeafletGeocoding.Tasks.ReverseGeocode(a)},EsriLeafletGeocoding.Tasks.Suggest=Esri.Tasks.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category"},initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},within:function(a){a=L.latLngBounds(a),a=a.pad(.5);var b=a.getCenter(),c=a.getNorthWest();return this.params.location=b.lng+","+b.lat,this.params.distance=Math.min(Math.max(b.distanceTo(c),2e3),5e4),this},nearby:function(a,b){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this.params.distance=Math.min(Math.max(b,2e3),5e4),this},run:function(a,b){return this.request(function(c,d){a.call(b,c,d,d)},this)}}),EsriLeafletGeocoding.Tasks.suggest=function(a){return new EsriLeafletGeocoding.Tasks.Suggest(a)},EsriLeafletGeocoding.Services.Geocoding=Esri.Services.Service.extend({includes:L.Mixin.Events,initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Services.Service.prototype.initialize.call(this,a)},geocode:function(){return new EsriLeafletGeocoding.Tasks.Geocode(this)},reverse:function(){return new EsriLeafletGeocoding.Tasks.ReverseGeocode(this)},suggest:function(){return this.options.url!==EsriLeafletGeocoding.WorldGeocodingService&&console&&console.warn?void console.warn("Only the ArcGIS Online World Geocoder supports suggestions"):new EsriLeafletGeocoding.Tasks.Suggest(this)}}),EsriLeafletGeocoding.Services.geocoding=function(a){return new EsriLeafletGeocoding.Services.Geocoding(a)},EsriLeafletGeocoding.Controls.Geosearch=L.Control.extend({includes:L.Mixin.Events,options:{position:"topleft",zoomToResult:!0,useMapBounds:12,collapseAfterResult:!0,expanded:!1,forStorage:!1,allowMultipleResults:!0,useArcgisWorldGeocoder:!0,providers:[],placeholder:"Search for places or addresses",title:"Location Search"},initialize:function(a){if(L.Util.setOptions(this,a),this.options.useArcgisWorldGeocoder){var b=new EsriLeafletGeocoding.Controls.Geosearch.Providers.ArcGISOnline;this.options.providers.push(b)}if(this.options.maxResults)for(var c=0;c<this.options.providers.length;c++)this.options.providers[c].options.maxResults=this.options.maxResults;this._pendingSuggestions=[]},_geocode:function(a,b,c){var d,e=0,f=[],g=L.Util.bind(function(b,c){e--,c&&(f=f.concat(c)),0>=e&&(d=this._boundsFromResults(f),this.fire("results",{results:f,bounds:d,latlng:d?d.getCenter():void 0,text:a}),this.options.zoomToResult&&d&&this._map.fitBounds(d),L.DomUtil.removeClass(this._input,"geocoder-control-loading"),this.fire("load"),this.clear(),this._input.blur())},this);if(b)e++,c.results(a,b,this._searchBounds(),g);else for(var h=0;h<this.options.providers.length;h++)e++,this.options.providers[h].results(a,b,this._searchBounds(),g)},_suggest:function(a){L.DomUtil.addClass(this._input,"geocoder-control-loading");var b=this.options.providers.length,c=L.Util.bind(function(a,c){return L.Util.bind(function(d,e){var f;if(b-=1,this._input.value<2)return this._suggestions.innerHTML="",void(this._suggestions.style.display="none");if(e)for(f=0;f<e.length;f++)e[f].provider=c;if(c._lastRender!==a&&c.nodes){for(f=0;f<c.nodes.length;f++)c.nodes[f].parentElement&&this._suggestions.removeChild(c.nodes[f]);c.nodes=[]}if(e.length&&this._input.value===a){if(c.nodes)for(var g=0;g<c.nodes.length;g++)c.nodes[g].parentElement&&this._suggestions.removeChild(c.nodes[g]);c._lastRender=a,c.nodes=this._renderSuggestions(e)}0===b&&L.DomUtil.removeClass(this._input,"geocoder-control-loading")},this)},this);this._pendingSuggestions=[];for(var d=0;d<this.options.providers.length;d++){var e=this.options.providers[d],f=e.suggestions(a,this._searchBounds(),c(a,e));this._pendingSuggestions.push(f)}},_searchBounds:function(){return this.options.useMapBounds===!1?null:this.options.useMapBounds===!0?this._map.getBounds():this.options.useMapBounds<=this._map.getZoom()?this._map.getBounds():null},_renderSuggestions:function(a){var b;this._suggestions.style.display="block",this._suggestions.style.maxHeight=this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10+"px";for(var c,d,e=[],f=0;f<a.length;f++){var g=a[f];!d&&this.options.providers.length>1&&b!==g.provider.options.label&&(d=L.DomUtil.create("span","geocoder-control-header",this._suggestions),d.textContent=g.provider.options.label,d.innerText=g.provider.options.label,b=g.provider.options.label,e.push(d)),c||(c=L.DomUtil.create("ul","geocoder-control-list",this._suggestions));var h=L.DomUtil.create("li","geocoder-control-suggestion",c);h.innerHTML=g.text,h.provider=g.provider,h["data-magic-key"]=g.magicKey}return e.push(c),e},_boundsFromResults:function(a){if(a.length){for(var b=new L.LatLngBounds([0,0],[0,0]),c=new L.LatLngBounds,d=a.length-1;d>=0;d--){var e=a[d];e.bounds.isValid()&&!e.bounds.equals(b)&&c.extend(e.bounds),c.extend(e.latlng)}return c}},clear:function(){this._suggestions.innerHTML="",this._suggestions.style.display="none",this._input.value="",this.options.collapseAfterResult&&(this._input.placeholder="",L.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")),!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom&&this._map.scrollWheelZoom.enable()},onAdd:function(a){return this._map=a,a.attributionControl&&a.attributionControl.addAttribution("Geocoding by Esri"),this._wrapper=L.DomUtil.create("div","geocoder-control "+(this.options.expanded?" geocoder-control-expanded":"")),this._input=L.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper),this._input.title=this.options.title,this._suggestions=L.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper),L.DomEvent.addListener(this._input,"focus",function(){this._input.placeholder=this.options.placeholder,L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this),L.DomEvent.addListener(this._wrapper,"click",function(){L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded"),this._input.focus()},this),L.DomEvent.addListener(this._suggestions,"mousedown",function(a){var b=a.target||a.srcElement;this._geocode(b.innerHTML,b["data-magic-key"],b.provider),this.clear()},this),L.DomEvent.addListener(this._input,"blur",function(){this.clear()},this),L.DomEvent.addListener(this._input,"keydown",function(a){L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");for(var b,c=this._suggestions.querySelectorAll(".geocoder-control-suggestion"),d=this._suggestions.querySelectorAll(".geocoder-control-selected")[0],e=0;e<c.length;e++)if(c[e]===d){b=e;break}switch(a.keyCode){case 13:d?(this._geocode(d.innerHTML,d["data-magic-key"],d.provider),this.clear()):this.options.allowMultipleResults?(this._geocode(this._input.value,void 0),this.clear()):L.DomUtil.addClass(c[0],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;case 38:d&&L.DomUtil.removeClass(d,"geocoder-control-selected");var f=c[b-1];d&&f?L.DomUtil.addClass(f,"geocoder-control-selected"):L.DomUtil.addClass(c[c.length-1],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;case 40:d&&L.DomUtil.removeClass(d,"geocoder-control-selected");var g=c[b+1];d&&g?L.DomUtil.addClass(g,"geocoder-control-selected"):L.DomUtil.addClass(c[0],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;default:for(var h=0;h<this._pendingSuggestions.length;h++){var i=this._pendingSuggestions[h];i&&i.abort&&!i.id?i.abort():i.id&&window._EsriLeafletCallbacks[i.id].abort&&window._EsriLeafletCallbacks[i.id].abort()}}},this),L.DomEvent.addListener(this._input,"keyup",L.Util.limitExecByInterval(function(a){var b=a.which||a.keyCode,c=(a.target||a.srcElement).value;return c.length<2?(this._suggestions.innerHTML="",this._suggestions.style.display="none",void L.DomUtil.removeClass(this._input,"geocoder-control-loading")):27===b?(this._suggestions.innerHTML="",void(this._suggestions.style.display="none")):void(13!==b&&38!==b&&40!==b&&this._input.value!==this._lastValue&&(this._lastValue=this._input.value,this._suggest(c)))},50,this),this),L.DomEvent.disableClickPropagation(this._wrapper),L.DomEvent.addListener(this._suggestions,"mouseover",function(){a.scrollWheelZoom.enabled()&&a.options.scrollWheelZoom&&a.scrollWheelZoom.disable()}),L.DomEvent.addListener(this._suggestions,"mouseout",function(){!a.scrollWheelZoom.enabled()&&a.options.scrollWheelZoom&&a.scrollWheelZoom.enable()}),this._wrapper},onRemove:function(a){a.attributionControl.removeAttribution("Geocoding by Esri")}}),EsriLeafletGeocoding.Controls.geosearch=function(a){return new EsriLeafletGeocoding.Controls.Geosearch(a)},EsriLeafletGeocoding.Controls.Geosearch.Providers={},EsriLeafletGeocoding.Controls.Geosearch.Providers.ArcGISOnline=EsriLeafletGeocoding.Services.Geocoding.extend({options:{label:"Places and Addresses",maxResults:5},suggestions:function(a,b,c){var d=this.suggest().text(a);return b&&d.within(b),d.run(function(a,b,d){var e=[];if(!a)for(;d.suggestions.length&&e.length<=this.options.maxResults-1;){var f=d.suggestions.shift();f.isCollection||e.push({text:f.text,magicKey:f.magicKey})}c(a,e)},this)},results:function(a,b,c,d){var e=this.geocode().text(a);return b?e.key(b):e.maxLocations(this.options.maxResults),c&&e.within(c),this.options.forStorage&&e.forStorage(!0),e.run(function(a,b){d(a,b.results)},this)}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer=L.esri.Services.FeatureLayer.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1e3,formatSuggestion:function(a){return a.properties[this.options.searchFields[0]]}},intialize:function(a,b){L.esri.Services.FeatureLayer.prototype.call(this,a,b),L.Util.setOptions(this,b),"string"==typeof this.options.searchFields&&(this.options.searchFields=[this.options.searchFields])},suggestions:function(a,b,c){var d=this.query().where(this._buildQuery(a)).returnGeometry(!1);b&&d.intersects(b),this.options.idField&&d.fields([this.options.idField].concat(this.options.searchFields));var e=d.run(function(a,b,d){if(a)c(a,[]);else{this.options.idField=d.objectIdFieldName;for(var e=[],f=Math.min(b.features.length,this.options.maxResults),g=0;f>g;g++){var h=b.features[g];e.push({text:this.options.formatSuggestion.call(this,h),magicKey:h.id})}c(a,e.slice(0,this.options.maxResults).reverse())}},this);return e},results:function(a,b,c,d){var e=this.query();return b?e.featureIds([b]):e.where(this._buildQuery(a)),c&&e.within(c),e.run(L.Util.bind(function(a,b){for(var c=[],e=0;e<b.features.length;e++){var f=b.features[e];if(f){var g=this._featureBounds(f),h={latlng:g.getCenter(),bounds:g,text:this.options.formatSuggestion.call(this,f),properties:f.properties};c.push(h)}}d(a,c)},this))},_buildQuery:function(a){for(var b=[],c=this.options.searchFields.length-1;c>=0;c--){var d=this.options.searchFields[c];b.push(d+" LIKE '%"+a+"%'")}return b.join(" OR ")},_featureBounds:function(a){var b=L.geoJson(a);if("Point"===a.geometry.type){var c=b.getBounds().getCenter();return new L.Circle(c,this.options.bufferRadius).getBounds()}return b.getBounds()}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.GeocodeService=EsriLeafletGeocoding.Services.Geocoding.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(a,b,c){return c(void 0,[]),!1},results:function(a,b,c,d){var e=this.geocode().text(a);return e.maxLocations(this.options.maxResults),c&&e.within(c),e.run(function(a,b){d(a,b.results)},this)}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.MapService=L.esri.Services.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(a){return a.properties[a.displayFieldName]+" <small>"+a.layerName+"</small>"}},initialize:function(a,b){L.esri.Services.MapService.prototype.initialize.call(this,a,b),this._getIdFields()},suggestions:function(a,b,c){var d=this.find().text(a).fields(this.options.searchFields).returnGeometry(!1).layers(this.options.layers);return d.run(function(a,b,d){var e=[];if(!a){var f=Math.min(this.options.maxResults,b.features.length);d.results=d.results.reverse();for(var g=0;f>g;g++){var h=b.features[g],i=d.results[g],j=i.layerId,k=this._idFields[j];h.layerId=j,h.layerName=this._layerNames[j],h.displayFieldName=this._displayFields[j],k&&e.push({text:this.options.formatSuggestion.call(this,h),magicKey:i.attributes[k]+":"+j})}}c(a,e.reverse())},this)},results:function(a,b,c,d){var e,f=[];if(b){var g=b.split(":")[0],h=b.split(":")[1];e=this.query().layer(h).featureIds(g)}else e=this.find().text(a).fields(this.options.searchFields).contains(!1).layers(this.options.layers);return e.run(function(a,b,c){if(!a){c.results&&(c.results=c.results.reverse());for(var e=0;e<b.features.length;e++){var g=b.features[e];if(h=h?h:c.results[e].layerId,g&&void 0!==h){{var i=this._featureBounds(g);this._idFields[h]}g.layerId=h,g.layerName=this._layerNames[h],g.displayFieldName=this._displayFields[h];var j={latlng:i.getCenter(),bounds:i,text:this.options.formatSuggestion.call(this,g),properties:g.properties};f.push(j)}}}d(a,f.reverse())},this)},_featureBounds:function(a){var b=L.geoJson(a);if("Point"===a.geometry.type){var c=b.getBounds().getCenter();return new L.Circle(c,this.options.bufferRadius).getBounds()}return b.getBounds()},_layerMetadataCallback:function(a){return L.Util.bind(function(b,c){this._displayFields[a]=c.displayField,this._layerNames[a]=c.name;for(var d=0;d<c.fields.length;d++){var e=c.fields[d];if("esriFieldTypeOID"===e.type){this._idFields[a]=e.name;break}}},this)},_getIdFields:function(){this._idFields={},this._displayFields={},this._layerNames={};for(var a=0;a<this.options.layers.length;a++){var b=this.options.layers[a];this.get(b,{},this._layerMetadataCallback(b))}}});
var protocol="https:"===window.location.protocol?"https:":"http:",EsriLeafletGeocoding={WorldGeocodingService:protocol+"//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/",Tasks:{},Services:{},Controls:{}};if("undefined"!=typeof window&&window.L&&window.L.esri&&(window.L.esri.Geocoding=EsriLeafletGeocoding),!Esri)var Esri=window.L.esri;EsriLeafletGeocoding.Tasks.Geocode=Esri.Tasks.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(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},within:function(a){return a=L.latLngBounds(a),this.params.bbox=Esri.Util.boundsToExtent(a),this},nearby:function(a,b){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this.params.distance=Math.min(Math.max(b,2e3),5e4),this},run:function(a,b){return 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(c,d){var e="find"===this.path?this._processFindResponse:this._processFindAddressCandidatesResponse,f=c?void 0:e(d);a.call(b,c,{results:f},d)},this)},_processFindResponse:function(a){for(var b=[],c=0;c<a.locations.length;c++){var d=a.locations[c];if(d.extent)var e=Esri.Util.extentToBounds(d.extent);b.push({text:d.name,bounds:e,score:d.feature.attributes.Score,latlng:new L.LatLng(d.feature.geometry.y,d.feature.geometry.x),properties:d.feature.attributes})}return b},_processFindAddressCandidatesResponse:function(a){for(var b=[],c=0;c<a.candidates.length;c++){var d=a.candidates[c],e=Esri.Util.extentToBounds(d.extent);b.push({text:d.address,bounds:e,score:d.score,latlng:new L.LatLng(d.location.y,d.location.x),properties:d.attributes})}return b}}),EsriLeafletGeocoding.Tasks.geocode=function(a){return new EsriLeafletGeocoding.Tasks.Geocode(a)},EsriLeafletGeocoding.Tasks.ReverseGeocode=Esri.Tasks.Task.extend({path:"reverseGeocode",params:{outSR:4326},setters:{distance:"distance",language:"language"},initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},latlng:function(a){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this},run:function(a,b){return this.request(function(c,d){var e;e=c?void 0:{latlng:new L.LatLng(d.location.y,d.location.x),address:d.address},a.call(b,c,e,d)},this)}}),EsriLeafletGeocoding.Tasks.reverseGeocode=function(a){return new EsriLeafletGeocoding.Tasks.ReverseGeocode(a)},EsriLeafletGeocoding.Tasks.Suggest=Esri.Tasks.Task.extend({path:"suggest",params:{},setters:{text:"text",category:"category"},initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Tasks.Task.prototype.initialize.call(this,a)},within:function(a){a=L.latLngBounds(a),a=a.pad(.5);var b=a.getCenter(),c=a.getNorthWest();return this.params.location=b.lng+","+b.lat,this.params.distance=Math.min(Math.max(b.distanceTo(c),2e3),5e4),this.params.searchExtent=L.esri.Util.boundsToExtent(a),this},nearby:function(a,b){return a=L.latLng(a),this.params.location=a.lng+","+a.lat,this.params.distance=Math.min(Math.max(b,2e3),5e4),this},run:function(a,b){return this.request(function(c,d){a.call(b,c,d,d)},this)}}),EsriLeafletGeocoding.Tasks.suggest=function(a){return new EsriLeafletGeocoding.Tasks.Suggest(a)},EsriLeafletGeocoding.Services.Geocoding=Esri.Services.Service.extend({includes:L.Mixin.Events,initialize:function(a){a=a||{},a.url=a.url||EsriLeafletGeocoding.WorldGeocodingService,Esri.Services.Service.prototype.initialize.call(this,a),this._confirmSuggestSupport()},geocode:function(){return new EsriLeafletGeocoding.Tasks.Geocode(this)},reverse:function(){return new EsriLeafletGeocoding.Tasks.ReverseGeocode(this)},suggest:function(){return new EsriLeafletGeocoding.Tasks.Suggest(this)},_confirmSuggestSupport:function(){this.metadata(function(a,b){b.capabilities.includes("Suggest")?this.options.supportsSuggest=!0:this.options.supportsSuggest=!1},this)}}),EsriLeafletGeocoding.Services.geocoding=function(a){return new EsriLeafletGeocoding.Services.Geocoding(a)},EsriLeafletGeocoding.Controls.Geosearch=L.Control.extend({includes:L.Mixin.Events,options:{position:"topleft",zoomToResult:!0,useMapBounds:12,collapseAfterResult:!0,expanded:!1,forStorage:!1,allowMultipleResults:!0,useArcgisWorldGeocoder:!0,providers:[],placeholder:"Search for places or addresses",title:"Location Search",mapAttribution:"Geocoding by Esri"},initialize:function(a){if(L.Util.setOptions(this,a),this.options.useArcgisWorldGeocoder){var b=new EsriLeafletGeocoding.Controls.Geosearch.Providers.ArcGISOnline;this.options.providers.push(b)}if(this.options.maxResults)for(var c=0;c<this.options.providers.length;c++)this.options.providers[c].options.maxResults=this.options.maxResults;this._pendingSuggestions=[]},_geocode:function(a,b,c){var d,e=0,f=[],g=L.Util.bind(function(b,c){e--,c&&(f=f.concat(c)),0>=e&&(d=this._boundsFromResults(f),this.fire("results",{results:f,bounds:d,latlng:d?d.getCenter():void 0,text:a}),this.options.zoomToResult&&d&&this._map.fitBounds(d),L.DomUtil.removeClass(this._input,"geocoder-control-loading"),this.fire("load"),this.clear(),this._input.blur())},this);if(b)e++,c.results(a,b,this._searchBounds(),g);else for(var h=0;h<this.options.providers.length;h++)e++,this.options.providers[h].results(a,b,this._searchBounds(),g)},_suggest:function(a){L.DomUtil.addClass(this._input,"geocoder-control-loading");var b=this.options.providers.length,c=L.Util.bind(function(a,c){return L.Util.bind(function(d,e){var f;if(b-=1,this._input.value<2)return this._suggestions.innerHTML="",void(this._suggestions.style.display="none");if(e)for(f=0;f<e.length;f++)e[f].provider=c;if(c._lastRender!==a&&c.nodes){for(f=0;f<c.nodes.length;f++)c.nodes[f].parentElement&&this._suggestions.removeChild(c.nodes[f]);c.nodes=[]}if(e.length&&this._input.value===a){if(c.nodes)for(var g=0;g<c.nodes.length;g++)c.nodes[g].parentElement&&this._suggestions.removeChild(c.nodes[g]);c._lastRender=a,c.nodes=this._renderSuggestions(e)}0===b&&L.DomUtil.removeClass(this._input,"geocoder-control-loading")},this)},this);this._pendingSuggestions=[];for(var d=0;d<this.options.providers.length;d++){var e=this.options.providers[d],f=e.suggestions(a,this._searchBounds(),c(a,e));this._pendingSuggestions.push(f)}},_searchBounds:function(){return this.options.useMapBounds===!1?null:this.options.useMapBounds===!0?this._map.getBounds():this.options.useMapBounds<=this._map.getZoom()?this._map.getBounds():null},_renderSuggestions:function(a){var b;this._suggestions.style.display="block",this._suggestions.style.maxHeight=this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10+"px";for(var c,d,e=[],f=0;f<a.length;f++){var g=a[f];!d&&this.options.providers.length>1&&b!==g.provider.options.label&&(d=L.DomUtil.create("span","geocoder-control-header",this._suggestions),d.textContent=g.provider.options.label,d.innerText=g.provider.options.label,b=g.provider.options.label,e.push(d)),c||(c=L.DomUtil.create("ul","geocoder-control-list",this._suggestions));var h=L.DomUtil.create("li","geocoder-control-suggestion",c);h.innerHTML=g.text,h.provider=g.provider,h["data-magic-key"]=g.magicKey}return e.push(c),e},_boundsFromResults:function(a){if(a.length){for(var b=new L.LatLngBounds([0,0],[0,0]),c=new L.LatLngBounds,d=a.length-1;d>=0;d--){var e=a[d];e.bounds&&e.bounds.isValid()&&!e.bounds.equals(b)&&c.extend(e.bounds),c.extend(e.latlng)}return c}},clear:function(){this._suggestions.innerHTML="",this._suggestions.style.display="none",this._input.value="",this.options.collapseAfterResult&&(this._input.placeholder="",L.DomUtil.removeClass(this._wrapper,"geocoder-control-expanded")),!this._map.scrollWheelZoom.enabled()&&this._map.options.scrollWheelZoom&&this._map.scrollWheelZoom.enable()},onAdd:function(a){return this._map=a,a.attributionControl&&a.attributionControl.addAttribution(this.options.useArcgisWorldGeocoder?"Geocoding by Esri":this.options.mapAttribution),this._wrapper=L.DomUtil.create("div","geocoder-control "+(this.options.expanded?" geocoder-control-expanded":"")),this._input=L.DomUtil.create("input","geocoder-control-input leaflet-bar",this._wrapper),this._input.title=this.options.title,this._suggestions=L.DomUtil.create("div","geocoder-control-suggestions leaflet-bar",this._wrapper),L.DomEvent.addListener(this._input,"focus",function(a){this._input.placeholder=this.options.placeholder,L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded")},this),L.DomEvent.addListener(this._wrapper,"click",function(a){L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded"),this._input.focus()},this),L.DomEvent.addListener(this._suggestions,"mousedown",function(a){var b=a.target||a.srcElement;this._geocode(b.innerHTML,b["data-magic-key"],b.provider),this.clear()},this),L.DomEvent.addListener(this._input,"blur",function(a){this.clear()},this),L.DomEvent.addListener(this._input,"keydown",function(a){L.DomUtil.addClass(this._wrapper,"geocoder-control-expanded");for(var b,c=this._suggestions.querySelectorAll(".geocoder-control-suggestion"),d=this._suggestions.querySelectorAll(".geocoder-control-selected")[0],e=0;e<c.length;e++)if(c[e]===d){b=e;break}switch(a.keyCode){case 13:d?(this._geocode(d.innerHTML,d["data-magic-key"],d.provider),this.clear()):this.options.allowMultipleResults?(this._geocode(this._input.value,void 0),this.clear()):L.DomUtil.addClass(c[0],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;case 38:d&&L.DomUtil.removeClass(d,"geocoder-control-selected");var f=c[b-1];d&&f?L.DomUtil.addClass(f,"geocoder-control-selected"):L.DomUtil.addClass(c[c.length-1],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;case 40:d&&L.DomUtil.removeClass(d,"geocoder-control-selected");var g=c[b+1];d&&g?L.DomUtil.addClass(g,"geocoder-control-selected"):L.DomUtil.addClass(c[0],"geocoder-control-selected"),L.DomEvent.preventDefault(a);break;default:for(var h=0;h<this._pendingSuggestions.length;h++){var i=this._pendingSuggestions[h];i&&i.abort&&!i.id?i.abort():i.id&&window._EsriLeafletCallbacks[i.id].abort&&window._EsriLeafletCallbacks[i.id].abort()}}},this),L.DomEvent.addListener(this._input,"keyup",L.Util.limitExecByInterval(function(a){var b=a.which||a.keyCode,c=(a.target||a.srcElement).value;return c.length<2?(this._suggestions.innerHTML="",this._suggestions.style.display="none",void L.DomUtil.removeClass(this._input,"geocoder-control-loading")):27===b?(this._suggestions.innerHTML="",void(this._suggestions.style.display="none")):void(13!==b&&38!==b&&40!==b&&this._input.value!==this._lastValue&&(this._lastValue=this._input.value,this._suggest(c)))},50,this),this),L.DomEvent.disableClickPropagation(this._wrapper),L.DomEvent.addListener(this._suggestions,"mouseover",function(b){a.scrollWheelZoom.enabled()&&a.options.scrollWheelZoom&&a.scrollWheelZoom.disable()}),L.DomEvent.addListener(this._suggestions,"mouseout",function(b){!a.scrollWheelZoom.enabled()&&a.options.scrollWheelZoom&&a.scrollWheelZoom.enable()}),this._wrapper},onRemove:function(a){a.attributionControl.removeAttribution("Geocoding by Esri")}}),EsriLeafletGeocoding.Controls.geosearch=function(a){return new EsriLeafletGeocoding.Controls.Geosearch(a)},EsriLeafletGeocoding.Controls.Geosearch.Providers={},EsriLeafletGeocoding.Controls.Geosearch.Providers.ArcGISOnline=EsriLeafletGeocoding.Services.Geocoding.extend({options:{label:"Places and Addresses",maxResults:5},suggestions:function(a,b,c){var d=this.suggest().text(a);return b&&d.within(b),d.run(function(a,b,d){var e=[];if(!a)for(;d.suggestions.length&&e.length<=this.options.maxResults-1;){var f=d.suggestions.shift();f.isCollection||e.push({text:f.text,magicKey:f.magicKey})}c(a,e)},this)},results:function(a,b,c,d){var e=this.geocode().text(a);return b?e.key(b):e.maxLocations(this.options.maxResults),c&&e.within(c),this.options.forStorage&&e.forStorage(!0),e.run(function(a,b){d(a,b.results)},this)}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer=L.esri.Services.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1e3,formatSuggestion:function(a){return a.properties[this.options.searchFields[0]]}},initialize:function(a){a.url=L.esri.Util.cleanUrl(a.url),L.esri.Services.FeatureLayerService.prototype.initialize.call(this,a),L.Util.setOptions(this,a),"string"==typeof this.options.searchFields&&(this.options.searchFields=[this.options.searchFields])},suggestions:function(a,b,c){var d=this.query().where(this._buildQuery(a)).returnGeometry(!1);b&&d.intersects(b),this.options.idField&&d.fields([this.options.idField].concat(this.options.searchFields));var e=d.run(function(a,b,d){if(a)c(a,[]);else{this.options.idField=d.objectIdFieldName;for(var e=[],f=Math.min(b.features.length,this.options.maxResults),g=0;f>g;g++){var h=b.features[g];e.push({text:this.options.formatSuggestion.call(this,h),magicKey:h.id})}c(a,e.slice(0,this.options.maxResults).reverse())}},this);return e},results:function(a,b,c,d){var e=this.query();return b?e.featureIds([b]):e.where(this._buildQuery(a)),c&&e.within(c),e.run(L.Util.bind(function(a,b){for(var c=[],e=0;e<b.features.length;e++){var f=b.features[e];if(f){var g=this._featureBounds(f),h={latlng:g.getCenter(),bounds:g,text:this.options.formatSuggestion.call(this,f),properties:f.properties};c.push(h)}}d(a,c)},this))},_buildQuery:function(a){for(var b=[],c=this.options.searchFields.length-1;c>=0;c--){var d=this.options.searchFields[c];b.push(d+" LIKE '%"+a+"%'")}return b.join(" OR ")},_featureBounds:function(a){var b=L.geoJson(a);if("Point"===a.geometry.type){var c=b.getBounds().getCenter();return new L.Circle(c,this.options.bufferRadius).getBounds()}return b.getBounds()}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.GeocodeService=EsriLeafletGeocoding.Services.Geocoding.extend({options:{label:"Geocode Server",maxResults:5},suggestions:function(a,b,c){if(this.options.supportsSuggest){var d=this.suggest().text(a);return b&&d.within(b),d.run(function(a,b,d){var e=[];if(!a)for(;d.suggestions.length&&e.length<=this.options.maxResults-1;){var f=d.suggestions.shift();f.isCollection||e.push({text:f.text,magicKey:f.magicKey})}c(a,e)},this)}return c(void 0,[]),!1},results:function(a,b,c,d){var e=this.geocode().text(a);return e.maxLocations(this.options.maxResults),c&&e.within(c),e.run(function(a,b){d(a,b.results)},this)}}),EsriLeafletGeocoding.Controls.Geosearch.Providers.MapService=L.esri.Services.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(a){return a.properties[a.displayFieldName]+" <small>"+a.layerName+"</small>"}},initialize:function(a){L.esri.Services.MapService.prototype.initialize.call(this,a),this._getIdFields()},suggestions:function(a,b,c){var d=this.find().text(a).fields(this.options.searchFields).returnGeometry(!1).layers(this.options.layers);return d.run(function(a,b,d){var e=[];if(!a){var f=Math.min(this.options.maxResults,b.features.length);d.results=d.results.reverse();for(var g=0;f>g;g++){var h=b.features[g],i=d.results[g],j=i.layerId,k=this._idFields[j];h.layerId=j,h.layerName=this._layerNames[j],h.displayFieldName=this._displayFields[j],k&&e.push({text:this.options.formatSuggestion.call(this,h),magicKey:i.attributes[k]+":"+j})}}c(a,e.reverse())},this)},results:function(a,b,c,d){var e,f=[];if(b){var g=b.split(":")[0],h=b.split(":")[1];e=this.query().layer(h).featureIds(g)}else e=this.find().text(a).fields(this.options.searchFields).contains(!1).layers(this.options.layers);return e.run(function(a,b,c){if(!a){c.results&&(c.results=c.results.reverse());for(var e=0;e<b.features.length;e++){var g=b.features[e];if(h=h?h:c.results[e].layerId,g&&void 0!==h){{var i=this._featureBounds(g);this._idFields[h]}g.layerId=h,g.layerName=this._layerNames[h],g.displayFieldName=this._displayFields[h];var j={latlng:i.getCenter(),bounds:i,text:this.options.formatSuggestion.call(this,g),properties:g.properties};f.push(j)}}}d(a,f.reverse())},this)},_featureBounds:function(a){var b=L.geoJson(a);if("Point"===a.geometry.type){var c=b.getBounds().getCenter();return new L.Circle(c,this.options.bufferRadius).getBounds()}return b.getBounds()},_layerMetadataCallback:function(a){return L.Util.bind(function(b,c){this._displayFields[a]=c.displayField,this._layerNames[a]=c.name;for(var d=0;d<c.fields.length;d++){var e=c.fields[d];if("esriFieldTypeOID"===e.type){this._idFields[a]=e.name;break}}},this)},_getIdFields:function(){this._idFields={},this._displayFields={},this._layerNames={};for(var a=0;a<this.options.layers.length;a++){var b=this.options.layers[a];this.get(b,{},this._layerMetadataCallback(b))}}});
//# sourceMappingURL=esri-leaflet-geocoder.js.map

@@ -27,0 +27,0 @@

@@ -86,3 +86,2 @@ var fs = require('fs');

preserveComments: 'some',
report: 'gzip',
banner: copyright + umdHeader,

@@ -115,4 +114,3 @@ footer: umdFooter,

wrap: false,
preserveComments: 'some',
report: 'gzip'
preserveComments: 'some'
},

@@ -127,28 +125,2 @@ files: {

s3: {
options: {
key: '<%= aws.key %>',
secret: '<%= aws.secret %>',
bucket: '<%= aws.bucket %>',
access: 'public-read',
headers: {
// 1 Year cache policy (1000 * 60 * 60 * 24 * 365)
"Cache-Control": "max-age=630720000, public",
"Expires": new Date(Date.now() + 63072000000).toUTCString()
}
},
dev: {
upload: [
{
src: 'dist/*',
dest: 'esri-leaflet-geocoder/<%= pkg.version %>/'
},
{
src: 'dist/img/*',
dest: 'esri-leaflet-geocoder/<%= pkg.version %>/img'
}
]
}
},
karma: {

@@ -188,8 +160,2 @@ options: {

var awsExists = fs.existsSync(process.env.HOME + '/esri-leaflet-s3.json');
if (awsExists) {
grunt.config.set('aws', grunt.file.readJSON(process.env.HOME + '/esri-leaflet-s3.json'));
}
grunt.registerTask('test', 'karma:run');

@@ -199,3 +165,3 @@ grunt.registerTask('default', ['build']);

grunt.registerTask('prepublish', ['concat', 'uglify', 'imagemin', 'cssmin']);
grunt.registerTask('release', ['releaseable', 's3']);
grunt.registerTask('release', ['releaseable']);

@@ -209,5 +175,4 @@ grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('grunt-releaseable');
};
};
{
"name": "esri-leaflet-geocoder",
"version": "1.0.0-rc.4",
"version": "1.0.0",
"description": "Esri Geocoding utilities and search plguin for Leaflet.",

@@ -12,4 +12,4 @@ "homepage": "https://github.com/Esri/esri-leaflet-geocoder",

"scripts": {
"prepublish": "node -e \"require('grunt').tasks(['prepublish']);\"",
"test": "node -e \"require('grunt').tasks(['test']);\""
"prepublish": "grunt prepublish",
"test": "grunt test"
},

@@ -26,3 +26,2 @@ "devDependencies": {

"grunt-releaseable": "0.0.14",
"grunt-s3": "^0.2.0-alpha.3",
"karma": "^0.12.24",

@@ -40,3 +39,4 @@ "karma-chai-sinon": "^0.1.3",

"contributors": [
"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)"
"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)",
"John Gravois <jgravois@esri.com> (http://johngravois.com)"
],

@@ -46,5 +46,5 @@ "license": "Apache 2.0",

"dependencies": {
"leaflet": "^0.7.0",
"esri-leaflet": "1.0.0-rc.5"
"leaflet": "^0.7.3",
"esri-leaflet": "^1.0.0"
}
}

@@ -42,3 +42,3 @@ # Esri Leaflet Geocoder

<!-- Esri Leaflet Geocoder -->
<script src="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.3/esri-leaflet-geocoder.js"></script>
<script src="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.4/esri-leaflet-geocoder.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn-geoweb.s3.amazonaws.com/esri-leaflet-geocoder/0.0.1-beta.3/esri-leaflet-geocoder.css">

@@ -89,3 +89,3 @@ </head>

`collapseAfterResult` | `Boolean` | `true` | If the geocoder is expanded after a result this will collapse it.
`expanded` | `Boolean` | `true` | Start the control in an expanded state.
`expanded` | `Boolean` | `false` | Start the control in an expanded state.
`maxResults` | `Integer` | `25` | The maximum number of results to return from a geocoding request. Max is 50.

@@ -97,2 +97,3 @@ `allowMultipleResults` | `Boolean` | `true` | If set to `true` and the user submits the form without a suggestion selected geocodes the current text in the input and zooms the user to view all the results.

`title` | `String` | `Location Search` | Title text for the search input. Shows as tool tip on hover.
`mapAttribution` | `String` | `Geocoding by Esri` | Custom geocoding attribution to be added to map. This setting is ignored and the default attribution is used if `useArcgisworldgeocoder` is `true`.

@@ -130,6 +131,7 @@ ### Methods

The `Geosearch` control can also search for results from a varity of sources including Feature Layers and Map Services. This is done with plain text matching and is not "real" geocoding. But it allows you to mix custom results into search box.
The `Geosearch` control can also search for results from a variety of sources including Feature Layers and Map Services. This is done with plain text matching and is not "real" geocoding. But it allows you to mix custom results into a search box.
```js
var gisDay = new L.esri.Geocoding.Controls.Geosearch.Providers.FeatureLayer('https://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/GIS_Day_Final/FeatureServer/0', {
var gisDay = new L.esri.Geocoding.Controls.Geosearch.Providers.FeatureLayer({
url: 'https://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/GIS_Day_Final/FeatureServer/0',
searchFields: ['Name', 'Organization'], // Search these fields for text matches

@@ -152,3 +154,3 @@ label: 'GIS Day Events', // Group suggestions under this header

* `L.esri.Geocoding.Controls.Geosearch.Providers.MapService` - Uses the find and query methods on the Map Service to get text matches.
* `L.esri.Geocoding.Controls.Geosearch.Providers.GeocodeService` - Use a ArcGIS Server Geocode Service. This option does not support suggestions.
* `L.esri.Geocoding.Controls.Geosearch.Providers.GeocodeService` - Use a ArcGIS Server Geocode Service.

@@ -159,8 +161,9 @@ #### Provider Options

--- | --- | --- | ---
`url` | `String` | Depends | The URL for the service that will be used to search. Varys by provider, usually a service or layer URL or a geocoding service URL.
`searchFields` | `Array[Strings]` | None | An array of fields to search for text. Not valid for the `ArcGISOnline` and `GeocodeService` providers.
`layer` | `Integer` | `0` | Only valid for `MapService` providers, the layer to find text matches on.
`label` | `String` | Provider Type | Text that will be used to group suggestions under.
`label` | `String` | Provider Type | Text that will be used to group suggestions under when more than one provider is being used.
`maxResults` | `Integer` | 5 | Maximum number of results to show for this provider.
`bufferRadius`, | `Integer` | If a service or layer contains points, buffer points by this radius to create bounds. Not valid for the `ArcGISOnline` and `GeocodeService` providers
`formatSuggestion`| `Function` | See Description | Formating function for the suggestion text. Receives a feature and returns a string.
`formatSuggestion`| `Function` | See Description | Formating function for the suggestion text from `FeatureLayer` provider. Receives a feature and returns a string.

@@ -194,7 +197,7 @@ #### Results Event

--- | ---
`new L.esri.Geocoding.Geocoding(url, options)`<br>`L.esri.Controls.geosearch(url, options)`<br>`new L.esri.Services.Geocoding(options)`<br>`L.esri.Controls.geosearch(options)` | Creates a new Geosearch control. You can pass the url as the first parameter or as `url` in the options to a custom geocoding endpoint if you do not want to use the ArcGIS Online World Geocoding service.
`new L.esri.Geocoding.Services.Geocoding(options)`<br>`L.esri.Geocoding.Services.geocoding(options)` | Creates a new Geocoding service. You can pass the `url` in the options to reference a custom geocoding endpoint if you do not want to use the ArcGIS Online World Geocoding service.
### Options
You can pass any options you can pass to L.esri.Services.Service.
You can pass any options you can pass to L.esri.Services.Service. `url` will be the ArcGIS World Geocoder by default but a custom geocoding service can also be used.

@@ -219,7 +222,7 @@ ### Methods

--- | ---
`new L.esri.Geocoding.Tasks.Geocode(url, options)`<br>`L.esri.Geocoding.Tasks.geocode(url, options)` | Creates a new Geocode task. `L.esri.Geocoding.WorldGeocodingService` can be used as a reference to the ArcGIS Online World Geocoder.
`new L.esri.Geocoding.Tasks.Geocode(options)`<br>`L.esri.Geocoding.Tasks.geocode(options)` | Creates a new Geocode task.
### Options
You can pass any options you can pass to L.esri.Tasks.Task.
You can pass any options you can pass to L.esri.Tasks.Task. `url` will be the [ArcGIS World Geocoder](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm) by default but a custom geocoding service can also be used.

@@ -238,3 +241,3 @@ ### Methods

`country(text <String>)` | Specify the country to be geocoded.
`category(category <String>)` | The category to search for suggestions. By default no category. A list of categories can be found here https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B
`category(category <String>)` | The category to search for suggestions. By default no category. A list of categories can be found [here](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B)
`within(bounds <L.LatLngBounds>)` | A bounding box to search for suggestions in.

@@ -247,3 +250,3 @@ `nearby(latlng <L.LatLng>, distance <Integer>)` | Searches for suggestions only inside an area around the LatLng. `distance` is in meters.

```js
L.esri.Geocoding.Tasks.geocode(L.esri.Geocoding.WorldGeocodingService).text('380 New York St, Redlands, California, 92373').run(function(err, results, response){
L.esri.Geocoding.Tasks.geocode().text('380 New York St, Redlands, California, 92373').run(function(err, results, response){
console.log(results);

@@ -254,3 +257,3 @@ });

```js
L.esri.Geocoding.Tasks.geocode(L.esri.Geocoding.WorldGeocodingService).address('380 New York St').city('Redlands').region('California').postal(92373).run(function(err, results, response){
L.esri.Geocoding.Tasks.geocode().address('380 New York St').city('Redlands').region('California').postal(92373).run(function(err, results, response){
console.log(results);

@@ -266,3 +269,3 @@ });

L.esri.Geocoding.Tasks.geocode(L.esri.Geocoding.WorldGeocodingService).text("Denver").within(bounds).run(function(err, response){
L.esri.Geocoding.Tasks.geocode().text("Denver").within(bounds).run(function(err, response){
console.log(response);

@@ -276,3 +279,3 @@ });

L.esri.Geocoding.Tasks.geocode(L.esri.Geocoding.WorldGeocodingService).text("Highlands Ranch").nearby(denver, 20000).run(function(err, response){
L.esri.Geocoding.Tasks.geocode().text("Highlands Ranch").nearby(denver, 20000).run(function(err, response){
console.log(response);

@@ -309,7 +312,7 @@ });

--- | ---
`new L.esri.Geocoding.Tasks.Suggest(url, options)`<br>`L.esri.Geocoding.Tasks.suggest(url, options)` | Creates a new Suggest task. `L.esri.Geocoding.WorldGeocodingService` can be used as a reference to the ArcGIS Online World Geocoder.
`new L.esri.Geocoding.Tasks.Suggest(options)`<br>`L.esri.Geocoding.Tasks.suggest(options)` | Creates a new Suggest task using the ArcGIS World Geocoder.
### Options
You can pass any options you can pass to L.esri.Tasks.Task.
You can pass any options you can pass to L.esri.Tasks.Task. `url` will be the [ArcGIS World Geocoder](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm) by default but a custom geocoding service can also be used.

@@ -321,3 +324,3 @@ ### Methods

`text(text <String>)` | `this` | The text to recive suggestions for.
`category(category <String>)` | The category to search for suggestions. By default no categogy. A list of categories can be found here https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B
`category(category <String>)` | The category to search for suggestions. By default no categogy. A list of categories can be found [here](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B)
`within(bounds <L.LatLngBounds>)` | A bounding box to search for suggestions in.

@@ -341,7 +344,7 @@ `nearby(latlng <L.LatLng>, distance <Integer>)` | Searches for suggestions only inside an area around the LatLng. `distance` is in meters.

--- | ---
`new L.esri.Geocoding.Tasks.ReverseGeocode(url, options)`<br>`L.esri.Geocoding.Tasks.reverseGeocode(url, options)` | Creates a new ReverseGeocode task. `L.esri.Geocoding.WorldGeocodingService` can be used as a reference to the ArcGIS Online World Geocoder.
`new L.esri.Geocoding.Tasks.ReverseGeocode(options)`<br>`L.esri.Geocoding.Tasks.reverseGeocode(options)` | Creates a new ReverseGeocode task. `L.esri.Geocoding.WorldGeocodingService` can be used as a reference to the [ArcGIS World Geocoder](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm).
### Options
You can pass any options you can pass to L.esri.Tasks.Task.
You can pass any options you can pass to L.esri.Tasks.Task. `url` will be the ArcGIS World Geocoder by default but a custom geocoding service can also be used.

@@ -377,3 +380,3 @@ ### Methods

Esri Leaflet Geocoder relies on the minimal Esri Leaflet Core which handles abstraction for requests and authentication when neccessary. You can find out more about the Esri Leaflet Core on the [Esri Leaflet downloads page](http://esri.github.com/esri-leaflet/downloads).
Esri Leaflet Geocoder relies on the minimal Esri Leaflet Core which handles abstraction for requests and authentication when neccessary. You can find out more about the Esri Leaflet Core from the [Esri Leaflet Quickstart](http://esri.github.io/esri-leaflet/examples/).

@@ -407,3 +410,3 @@ ## Resources

## Licensing
Copyright 2013 Esri
Copyright 2015 Esri

@@ -410,0 +413,0 @@ Licensed under the Apache License, Version 2.0 (the "License");

@@ -14,3 +14,4 @@ EsriLeafletGeocoding.Controls.Geosearch = L.Control.extend({

placeholder: 'Search for places or addresses',
title: 'Location Search'
title: 'Location Search',
mapAttribution: 'Geocoding by Esri'
},

@@ -209,3 +210,3 @@

// make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present
if(result.bounds.isValid() && !result.bounds.equals(nullIsland)){
if(result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)){
bounds.extend(result.bounds);

@@ -239,4 +240,9 @@ }

// Add geocoding attribution to map. Using World Geocode Service requires default attribution.
if (map.attributionControl) {
map.attributionControl.addAttribution('Geocoding by Esri');
if (this.options.useArcgisWorldGeocoder) {
map.attributionControl.addAttribution('Geocoding by Esri');
} else {
map.attributionControl.addAttribution(this.options.mapAttribution);
}
}

@@ -396,2 +402,2 @@

EsriLeafletGeocoding.Controls.Geosearch.Providers = {};
EsriLeafletGeocoding.Controls.Geosearch.Providers = {};

@@ -1,2 +0,2 @@

EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer = L.esri.Services.FeatureLayer.extend({
EsriLeafletGeocoding.Controls.Geosearch.Providers.FeatureLayer = L.esri.Services.FeatureLayerService.extend({
options: {

@@ -10,4 +10,5 @@ label: 'Feature Layer',

},
intialize: function(url, options){
L.esri.Services.FeatureLayer.prototype.call(this, url, options);
initialize: function(options){
options.url = L.esri.Util.cleanUrl(options.url);
L.esri.Services.FeatureLayerService.prototype.initialize.call(this, options);
L.Util.setOptions(this, options);

@@ -102,2 +103,2 @@ if(typeof this.options.searchFields === 'string'){

}
});
});

@@ -8,4 +8,30 @@ EsriLeafletGeocoding.Controls.Geosearch.Providers.GeocodeService = EsriLeafletGeocoding.Services.Geocoding.extend({

suggestions: function(text, bounds, callback){
callback(undefined, []);
return false;
if (this.options.supportsSuggest) {
var request = this.suggest().text(text);
if(bounds){
request.within(bounds);
}
return request.run(function(error, results, response){
var suggestions = [];
if(!error){
while(response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)){
var suggestion = response.suggestions.shift();
if(!suggestion.isCollection){
suggestions.push({
text: suggestion.text,
magicKey: suggestion.magicKey
});
}
}
}
callback(error, suggestions);
}, this);
}
else {
callback(undefined, []);
return false;
}
},

@@ -12,0 +38,0 @@

@@ -11,4 +11,4 @@ EsriLeafletGeocoding.Controls.Geosearch.Providers.MapService = L.esri.Services.MapService.extend({

},
initialize: function(url, options){
L.esri.Services.MapService.prototype.initialize.call(this, url, options);
initialize: function(options){
L.esri.Services.MapService.prototype.initialize.call(this, options);
this._getIdFields();

@@ -15,0 +15,0 @@ },

@@ -9,2 +9,3 @@ EsriLeafletGeocoding.Services.Geocoding = Esri.Services.Service.extend({

Esri.Services.Service.prototype.initialize.call(this, options);
this._confirmSuggestSupport();
},

@@ -21,7 +22,15 @@

suggest: function(){
if(this.options.url !== EsriLeafletGeocoding.WorldGeocodingService && console && console.warn){
console.warn('Only the ArcGIS Online World Geocoder supports suggestions');
return;
}
// requires either the Esri World Geocoding Service or a 10.3 ArcGIS Server Geocoding Service that supports suggest.
return new EsriLeafletGeocoding.Tasks.Suggest(this);
},
_confirmSuggestSupport: function(){
this.metadata(function(error, response) {
if (response.capabilities.includes('Suggest')) {
this.options.supportsSuggest = true;
}
else {
this.options.supportsSuggest = false;
}
}, this);
}

@@ -28,0 +37,0 @@ });

@@ -67,3 +67,5 @@ EsriLeafletGeocoding.Tasks.Geocode = Esri.Tasks.Task.extend({

var location = response.locations[i];
var bounds = Esri.Util.extentToBounds(location.extent);
if (location.extent) {
var bounds = Esri.Util.extentToBounds(location.extent);
}

@@ -70,0 +72,0 @@ results.push({

@@ -25,2 +25,3 @@ EsriLeafletGeocoding.Tasks.Suggest = Esri.Tasks.Task.extend({

this.params.distance = Math.min(Math.max(center.distanceTo(ne), 2000), 50000);
this.params.searchExtent = L.esri.Util.boundsToExtent(bounds);
return this;

@@ -27,0 +28,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc