diff --git a/dist/esri-leaflet-geocoder.css b/dist/esri-leaflet-geocoder.css new file mode 100644 index 0000000..b407bd2 --- /dev/null +++ b/dist/esri-leaflet-geocoder.css @@ -0,0 +1 @@ +.geocoder-control-input{position:absolute;left:0;top:0;background-color:white;background-repeat:no-repeat;background-image:url("img/search.png");background-size:26px;border:none;padding:0;text-indent:6px;font-size:13px;line-height:normal;height:auto;padding-top:5px;padding-bottom:5px;width:100%;background-position:right center;cursor:pointer;box-sizing:border-box}.geocoder-control{width:26px;height:26px;-webkit-transition:width 0.175s ease-in;-moz-transition:width 0.175s ease-in;-ms-transition:width 0.175s ease-in;-o-transition:width 0.175s ease-in;transition:width 0.175s ease-in}.geocoder-control-expanded,.leaflet-touch .geocoder-control-expanded{width:275px}.geocoder-control-input.geocoder-control-loading{background-image:url("img/loading.gif");background-size:26px}@media only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2){.geocoder-control-input{background-image:url("img/search@2x.png")}.geocoder-control-input.geocoder-control-loading{background-image:url("img/loading@2x.gif")}}.geocoder-control-input:focus{outline:none;cursor:text}.geocoder-control-input::-ms-clear{display:none}.geocoder-control-suggestions{width:100%;position:absolute;top:26px;left:0;margin-top:10px;overflow:auto;display:none}.geocoder-control-list+.geocoder-control-header{border-top:1px solid #d5d5d5}.geocoder-control-header{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#444;background:#F2F2F2;border-bottom:1px solid #d5d5d5;display:block;padding:.5em}.geocoder-control-list{list-style:none;margin:0;padding:0}.geocoder-control-suggestions .geocoder-control-suggestion{font-size:13px;padding:7px;background:white;border-top:1px solid #f1f1f1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.geocoder-control-suggestions .geocoder-control-suggestion:first-child{border:none}.geocoder-control-suggestions .geocoder-control-suggestion.geocoder-control-selected,.geocoder-control-suggestions .geocoder-control-suggestion:hover{background:#7FDFFF;border-color:#7FDFFF}.leaflet-right .geocoder-control-suggestions{left:auto;right:0}.leaflet-right .geocoder-control-input{left:auto;right:0}.leaflet-touch .geocoder-control{width:30px;height:30px}.leaflet-touch .geocoder-control.geocoder-control-expanded{width:275px}.leaflet-touch .geocoder-control-input{height:30px;line-height:30px;background-size:30px}.leaflet-touch .geocoder-control-suggestions{top:30px}.leaflet-oldie .geocoder-control-input{width:28px;height:28px}.leaflet-oldie .geocoder-control-expanded .geocoder-control-input{width:auto}.leaflet-oldie .geocoder-control-input,.leaflet-oldie .geocoder-control-suggestions{border:1px solid #999} diff --git a/dist/esri-leaflet-geocoder.js b/dist/esri-leaflet-geocoder.js new file mode 100644 index 0000000..2e22018 --- /dev/null +++ b/dist/esri-leaflet-geocoder.js @@ -0,0 +1,5 @@ +/* esri-leaflet-geocoder - v2.0.0 - Tue Sep 08 2015 16:07:48 GMT-0700 (PDT) + * Copyright (c) 2015 Environmental Systems Research Institute, Inc. + * Apache 2.0 */ +(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("leaflet"),require("esri-leaflet")):typeof define==="function"&&define.amd?define(["exports","leaflet","esri-leaflet"],factory):factory(global.L.esri.Geocoding={},L,L.esri)})(this,function(exports,L,esri_leaflet){"use strict";exports.Geocode=esri_leaflet.Task.extend({path:"find",params:{outSr:4326,forStorage:false,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(options){options=options||{};options.url=options.url||exports.WorldGeocodingServiceUrl;esri_leaflet.Task.prototype.initialize.call(this,options)},within:function(bounds){bounds=L.latLngBounds(bounds);this.params.bbox=esri_leaflet.Util.boundsToExtent(bounds);return this},nearby:function(latlng,radius){latlng=L.latLng(latlng);this.params.location=latlng.lng+","+latlng.lat;this.params.distance=Math.min(Math.max(radius,2e3),5e4);return this},run:function(callback,context){this.path=this.params.text?"find":"findAddressCandidates";if(this.path==="findAddressCandidates"&&this.params.bbox){this.params.searchExtent=this.params.bbox;delete this.params.bbox}return this.request(function(error,response){var processor=this.path==="find"?this._processFindResponse:this._processFindAddressCandidatesResponse;var results=!error?processor(response):undefined;callback.call(context,error,{results:results},response)},this)},_processFindResponse:function(response){var results=[];for(var i=0;i1&¤tGroup!==suggestion.provider.options.label){header=L.DomUtil.create("span","geocoder-control-header",this._suggestions);header.textContent=suggestion.provider.options.label;header.innerText=suggestion.provider.options.label;currentGroup=suggestion.provider.options.label;nodes.push(header)}if(!list){list=L.DomUtil.create("ul","geocoder-control-list",this._suggestions)}var suggestionItem=L.DomUtil.create("li","geocoder-control-suggestion",list);suggestionItem.innerHTML=suggestion.text;suggestionItem.provider=suggestion.provider;suggestionItem["data-magic-key"]=suggestion.magicKey}nodes.push(list);return nodes},_boundsFromResults:function(results){if(!results.length){return}var nullIsland=L.latLngBounds([0,0],[0,0]);var resultBounds=[];var resultLatlngs=[];for(var i=results.length-1;i>=0;i--){var result=results[i];resultLatlngs.push(result.latlng);if(result.bounds&&result.bounds.isValid()&&!result.bounds.equals(nullIsland)){resultBounds.push(result.bounds)}}var bounds=L.latLngBounds(resultLatlngs);for(var j=0;jGeocoding by Esri'},suggestions:function(text,bounds,callback){var request=this.suggest().text(text);if(bounds){request.within(bounds)}if(this.options.countries){request.countries(this.options.countries)}if(this.options.categories){request.category(this.options.categories)}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)},results:function(text,key,bounds,callback){var request=this.geocode().text(text);if(key){request.key(key)}else{request.maxLocations(this.options.maxResults)}if(bounds){request.within(bounds)}if(this.options.forStorage){request.forStorage(true)}return request.run(function(error,response){callback(error,response.results)},this)}});function arcgisOnlineProvider(options){return new exports.ArcgisOnlineProvider(options)}exports.FeatureLayerProvider=esri_leaflet.FeatureLayerService.extend({options:{label:"Feature Layer",maxResults:5,bufferRadius:1e3,formatSuggestion:function(feature){return feature.properties[this.options.searchFields[0]]}},initialize:function(options){esri_leaflet.FeatureLayerService.prototype.initialize.call(this,options);if(typeof this.options.searchFields==="string"){this.options.searchFields=[this.options.searchFields]}},suggestions:function(text,bounds,callback){var query=this.query().where(this._buildQuery(text)).returnGeometry(false);if(bounds){query.intersects(bounds)}if(this.options.idField){query.fields([this.options.idField].concat(this.options.searchFields))}var request=query.run(function(error,results,raw){if(error){callback(error,[])}else{this.options.idField=raw.objectIdFieldName;var suggestions=[];var count=Math.min(results.features.length,this.options.maxResults);for(var i=0;i=0;i--){var field='upper("'+this.options.searchFields[i]+'")';queryString.push(field+" LIKE upper('%"+text+"%')")}return queryString.join(" OR ")},_featureBounds:function(feature){var geojson=L.geoJson(feature);if(feature.geometry.type==="Point"){var center=geojson.getBounds().getCenter();var lngRadius=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*center.lat);var latRadius=this.options.bufferRadius/40075017*360;return L.latLngBounds([center.lat-latRadius,center.lng-lngRadius],[center.lat+latRadius,center.lng+lngRadius])}else{return geojson.getBounds()}}});function featureLayerProvider(options){return new exports.FeatureLayerProvider(options)}exports.MapServiceProvider=esri_leaflet.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(feature){return feature.properties[feature.displayFieldName]+" "+feature.layerName+""}},initialize:function(options){esri_leaflet.MapService.prototype.initialize.call(this,options);this._getIdFields()},suggestions:function(text,bounds,callback){var request=this.find().text(text).fields(this.options.searchFields).returnGeometry(false).layers(this.options.layers);return request.run(function(error,results,raw){var suggestions=[];if(!error){var count=Math.min(this.options.maxResults,results.features.length);raw.results=raw.results.reverse();for(var i=0;i 1 && currentGroup !== suggestion.provider.options.label) {\n header = L.DomUtil.create('span', 'geocoder-control-header', this._suggestions);\n header.textContent = suggestion.provider.options.label;\n header.innerText = suggestion.provider.options.label;\n currentGroup = suggestion.provider.options.label;\n nodes.push(header);\n }\n\n if (!list) {\n list = L.DomUtil.create('ul', 'geocoder-control-list', this._suggestions);\n }\n\n var suggestionItem = L.DomUtil.create('li', 'geocoder-control-suggestion', list);\n\n suggestionItem.innerHTML = suggestion.text;\n suggestionItem.provider = suggestion.provider;\n suggestionItem['data-magic-key'] = suggestion.magicKey;\n }\n\n nodes.push(list);\n\n return nodes;\n },\n\n _boundsFromResults: function (results) {\n if (!results.length) {\n return;\n }\n\n var nullIsland = L.latLngBounds([0, 0], [0, 0]);\n var resultBounds = [];\n var resultLatlngs = [];\n\n // collect the bounds and center of each result\n for (var i = results.length - 1; i >= 0; i--) {\n var result = results[i];\n\n resultLatlngs.push(result.latlng);\n\n // make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present\n if (result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)) {\n resultBounds.push(result.bounds);\n }\n }\n\n // form a bounds object containing all center points\n var bounds = L.latLngBounds(resultLatlngs);\n\n // and extend it to contain all bounds objects\n for (var j = 0; j < resultBounds.length; j++) {\n bounds.extend(resultBounds[i]);\n }\n\n return bounds;\n },\n\n clear: function () {\n this._suggestions.innerHTML = '';\n this._suggestions.style.display = 'none';\n this._input.value = '';\n\n if (this.options.collapseAfterResult) {\n this._input.placeholder = '';\n L.DomUtil.removeClass(this._wrapper, 'geocoder-control-expanded');\n }\n\n if (!this._map.scrollWheelZoom.enabled() && this._map.options.scrollWheelZoom) {\n this._map.scrollWheelZoom.enable();\n }\n },\n\n getAttribution: function () {\n var attribution = this.options.attribution;\n\n for (var i = 0; i < this._providers.length; i++) {\n attribution += (' ' + this._providers[i].options.attribution);\n }\n\n return attribution;\n },\n\n onAdd: function (map) {\n this._map = map;\n this._wrapper = L.DomUtil.create('div', 'geocoder-control ' + ((this.options.expanded) ? ' ' + 'geocoder-control-expanded' : ''));\n this._input = L.DomUtil.create('input', 'geocoder-control-input leaflet-bar', this._wrapper);\n this._input.title = this.options.title;\n\n this._suggestions = L.DomUtil.create('div', 'geocoder-control-suggestions leaflet-bar', this._wrapper);\n\n L.DomEvent.addListener(this._input, 'focus', function (e) {\n this._input.placeholder = this.options.placeholder;\n L.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n }, this);\n\n L.DomEvent.addListener(this._wrapper, 'click', function (e) {\n L.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n this._input.focus();\n }, this);\n\n L.DomEvent.addListener(this._suggestions, 'mousedown', function (e) {\n var suggestionItem = e.target || e.srcElement;\n this._geocode(suggestionItem.innerHTML, suggestionItem['data-magic-key'], suggestionItem.provider);\n this.clear();\n }, this);\n\n L.DomEvent.addListener(this._input, 'blur', function (e) {\n this.clear();\n }, this);\n\n L.DomEvent.addListener(this._input, 'keydown', function (e) {\n L.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n\n var list = this._suggestions.querySelectorAll('.' + 'geocoder-control-suggestion');\n var selected = this._suggestions.querySelectorAll('.' + 'geocoder-control-selected')[0];\n var selectedPosition;\n\n for (var i = 0; i < list.length; i++) {\n if (list[i] === selected) {\n selectedPosition = i;\n break;\n }\n }\n\n switch (e.keyCode) {\n case 13:\n if (selected) {\n this._geocode(selected.innerHTML, selected['data-magic-key'], selected.provider);\n this.clear();\n } else if (this.options.allowMultipleResults) {\n this._geocode(this._input.value, undefined);\n this.clear();\n } else {\n L.DomUtil.addClass(list[0], 'geocoder-control-selected');\n }\n L.DomEvent.preventDefault(e);\n break;\n case 38:\n if (selected) {\n L.DomUtil.removeClass(selected, 'geocoder-control-selected');\n }\n\n var previousItem = list[selectedPosition - 1];\n\n if (selected && previousItem) {\n L.DomUtil.addClass(previousItem, 'geocoder-control-selected');\n } else {\n L.DomUtil.addClass(list[list.length - 1], 'geocoder-control-selected');\n }\n L.DomEvent.preventDefault(e);\n break;\n case 40:\n if (selected) {\n L.DomUtil.removeClass(selected, 'geocoder-control-selected');\n }\n\n var nextItem = list[selectedPosition + 1];\n\n if (selected && nextItem) {\n L.DomUtil.addClass(nextItem, 'geocoder-control-selected');\n } else {\n L.DomUtil.addClass(list[0], 'geocoder-control-selected');\n }\n L.DomEvent.preventDefault(e);\n break;\n default:\n // when the input changes we should cancel all pending suggestion requests if possible to avoid result collisions\n for (var x = 0; x < this._pendingSuggestions.length; x++) {\n var request = this._pendingSuggestions[x];\n if (request && request.abort && !request.id) {\n request.abort();\n }\n }\n break;\n }\n }, this);\n\n L.DomEvent.addListener(this._input, 'keyup', L.Util.throttle(function (e) {\n var key = e.which || e.keyCode;\n var text = (e.target || e.srcElement).value;\n\n // require at least 2 characters for suggestions\n if (text.length < 2) {\n this._suggestions.innerHTML = '';\n this._suggestions.style.display = 'none';\n L.DomUtil.removeClass(this._input, 'geocoder-control-loading');\n return;\n }\n\n // if this is the escape key it will clear the input so clear suggestions\n if (key === 27) {\n this._suggestions.innerHTML = '';\n this._suggestions.style.display = 'none';\n return;\n }\n\n // if this is NOT the up/down arrows or enter make a suggestion\n if (key !== 13 && key !== 38 && key !== 40) {\n if (this._input.value !== this._lastValue) {\n this._lastValue = this._input.value;\n this._suggest(text);\n }\n }\n }, 50, this), this);\n\n L.DomEvent.disableClickPropagation(this._wrapper);\n\n // when mouse moves over suggestions disable scroll wheel zoom if its enabled\n L.DomEvent.addListener(this._suggestions, 'mouseover', function (e) {\n if (map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) {\n map.scrollWheelZoom.disable();\n }\n });\n\n // when mouse moves leaves suggestions enable scroll wheel zoom if its disabled\n L.DomEvent.addListener(this._suggestions, 'mouseout', function (e) {\n if (!map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) {\n map.scrollWheelZoom.enable();\n }\n });\n\n return this._wrapper;\n },\n\n onRemove: function (map) {\n map.attributionControl.removeAttribution('Geocoding by Esri');\n }\n});\n\nexport function geosearch (options) {\n return new Geosearch(options);\n}\n\nexport default geosearch;\n","import { GeocodeService } from '../Services/Geocode';\n\nexport var ArcgisOnlineProvider = GeocodeService.extend({\n options: {\n label: 'Places and Addresses',\n maxResults: 5,\n attribution: 'Geocoding by Esri'\n },\n\n suggestions: function (text, bounds, callback) {\n var request = this.suggest().text(text);\n\n if (bounds) {\n request.within(bounds);\n }\n\n if (this.options.countries) {\n request.countries(this.options.countries);\n }\n\n if (this.options.categories) {\n request.category(this.options.categories);\n }\n\n return request.run(function (error, results, response) {\n var suggestions = [];\n if (!error) {\n while (response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)) {\n var suggestion = response.suggestions.shift();\n if (!suggestion.isCollection) {\n suggestions.push({\n text: suggestion.text,\n magicKey: suggestion.magicKey\n });\n }\n }\n }\n callback(error, suggestions);\n }, this);\n },\n\n results: function (text, key, bounds, callback) {\n var request = this.geocode().text(text);\n\n if (key) {\n request.key(key);\n } else {\n request.maxLocations(this.options.maxResults);\n }\n\n if (bounds) {\n request.within(bounds);\n }\n\n if (this.options.forStorage) {\n request.forStorage(true);\n }\n\n return request.run(function (error, response) {\n callback(error, response.results);\n }, this);\n }\n});\n\nexport function arcgisOnlineProvider (options) {\n return new ArcgisOnlineProvider(options);\n}\n\nexport default arcgisOnlineProvider;\n","import L from 'leaflet';\nimport { FeatureLayerService } from 'esri-leaflet';\n\nexport var FeatureLayerProvider = FeatureLayerService.extend({\n options: {\n label: 'Feature Layer',\n maxResults: 5,\n bufferRadius: 1000,\n formatSuggestion: function (feature) {\n return feature.properties[this.options.searchFields[0]];\n }\n },\n\n initialize: function (options) {\n FeatureLayerService.prototype.initialize.call(this, options);\n if (typeof this.options.searchFields === 'string') {\n this.options.searchFields = [this.options.searchFields];\n }\n },\n\n suggestions: function (text, bounds, callback) {\n var query = this.query().where(this._buildQuery(text))\n .returnGeometry(false);\n\n if (bounds) {\n query.intersects(bounds);\n }\n\n if (this.options.idField) {\n query.fields([this.options.idField].concat(this.options.searchFields));\n }\n\n var request = query.run(function (error, results, raw) {\n if (error) {\n callback(error, []);\n } else {\n this.options.idField = raw.objectIdFieldName;\n var suggestions = [];\n var count = Math.min(results.features.length, this.options.maxResults);\n for (var i = 0; i < count; i++) {\n var feature = results.features[i];\n suggestions.push({\n text: this.options.formatSuggestion.call(this, feature),\n magicKey: feature.id\n });\n }\n callback(error, suggestions.slice(0, this.options.maxResults).reverse());\n }\n }, this);\n\n return request;\n },\n\n results: function (text, key, bounds, callback) {\n var query = this.query();\n\n if (key) {\n query.featureIds([key]);\n } else {\n query.where(this._buildQuery(text));\n }\n\n if (bounds) {\n query.within(bounds);\n }\n\n return query.run(L.Util.bind(function (error, features) {\n var results = [];\n for (var i = 0; i < features.features.length; i++) {\n var feature = features.features[i];\n if (feature) {\n var bounds = this._featureBounds(feature);\n\n var result = {\n latlng: bounds.getCenter(),\n bounds: bounds,\n text: this.options.formatSuggestion.call(this, feature),\n properties: feature.properties,\n geojson: feature\n };\n\n results.push(result);\n }\n }\n callback(error, results);\n }, this));\n },\n\n _buildQuery: function (text) {\n var queryString = [];\n\n for (var i = this.options.searchFields.length - 1; i >= 0; i--) {\n var field = 'upper(\"' + this.options.searchFields[i] + '\")';\n\n queryString.push(field + ' LIKE upper(\\'%' + text + '%\\')');\n }\n\n return queryString.join(' OR ');\n },\n\n _featureBounds: function (feature) {\n var geojson = L.geoJson(feature);\n if (feature.geometry.type === 'Point') {\n var center = geojson.getBounds().getCenter();\n var lngRadius = ((this.options.bufferRadius / 40075017) * 360) / Math.cos((180 / Math.PI) * center.lat);\n var latRadius = (this.options.bufferRadius / 40075017) * 360;\n return L.latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]);\n } else {\n return geojson.getBounds();\n }\n }\n});\n\nexport function featureLayerProvider (options) {\n return new FeatureLayerProvider(options);\n}\n\nexport default featureLayerProvider;\n","import L from 'leaflet';\nimport { MapService } from 'esri-leaflet';\n\nexport var MapServiceProvider = MapService.extend({\n options: {\n layers: [0],\n label: 'Map Service',\n bufferRadius: 1000,\n maxResults: 5,\n formatSuggestion: function (feature) {\n return feature.properties[feature.displayFieldName] + ' ' + feature.layerName + '';\n }\n },\n\n initialize: function (options) {\n MapService.prototype.initialize.call(this, options);\n this._getIdFields();\n },\n\n suggestions: function (text, bounds, callback) {\n var request = this.find().text(text).fields(this.options.searchFields).returnGeometry(false).layers(this.options.layers);\n\n return request.run(function (error, results, raw) {\n var suggestions = [];\n if (!error) {\n var count = Math.min(this.options.maxResults, results.features.length);\n raw.results = raw.results.reverse();\n for (var i = 0; i < count; i++) {\n var feature = results.features[i];\n var result = raw.results[i];\n var layer = result.layerId;\n var idField = this._idFields[layer];\n feature.layerId = layer;\n feature.layerName = this._layerNames[layer];\n feature.displayFieldName = this._displayFields[layer];\n if (idField) {\n suggestions.push({\n text: this.options.formatSuggestion.call(this, feature),\n magicKey: result.attributes[idField] + ':' + layer\n });\n }\n }\n }\n callback(error, suggestions.reverse());\n }, this);\n },\n\n results: function (text, key, bounds, callback) {\n var results = [];\n var request;\n\n if (key) {\n var featureId = key.split(':')[0];\n var layer = key.split(':')[1];\n request = this.query().layer(layer).featureIds(featureId);\n } else {\n request = this.find().text(text).fields(this.options.searchFields).contains(false).layers(this.options.layers);\n }\n\n return request.run(function (error, features, response) {\n if (!error) {\n if (response.results) {\n response.results = response.results.reverse();\n }\n for (var i = 0; i < features.features.length; i++) {\n var feature = features.features[i];\n layer = (layer) ? layer : response.results[i].layerId;\n if (feature && layer !== undefined) {\n var bounds = this._featureBounds(feature);\n feature.layerId = layer;\n feature.layerName = this._layerNames[layer];\n feature.displayFieldName = this._displayFields[layer];\n\n var result = {\n latlng: bounds.getCenter(),\n bounds: bounds,\n text: this.options.formatSuggestion.call(this, feature),\n properties: feature.properties,\n geojson: feature\n };\n\n results.push(result);\n }\n }\n }\n callback(error, results.reverse());\n }, this);\n },\n\n _featureBounds: function (feature) {\n var geojson = L.geoJson(feature);\n if (feature.geometry.type === 'Point') {\n var center = geojson.getBounds().getCenter();\n var lngRadius = ((this.options.bufferRadius / 40075017) * 360) / Math.cos((180 / Math.PI) * center.lat);\n var latRadius = (this.options.bufferRadius / 40075017) * 360;\n return L.latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]);\n } else {\n return geojson.getBounds();\n }\n },\n\n _layerMetadataCallback: function (layerid) {\n return L.Util.bind(function (error, metadata) {\n if (error) { return; }\n this._displayFields[layerid] = metadata.displayField;\n this._layerNames[layerid] = metadata.name;\n for (var i = 0; i < metadata.fields.length; i++) {\n var field = metadata.fields[i];\n if (field.type === 'esriFieldTypeOID') {\n this._idFields[layerid] = field.name;\n break;\n }\n }\n }, this);\n },\n\n _getIdFields: function () {\n this._idFields = {};\n this._displayFields = {};\n this._layerNames = {};\n for (var i = 0; i < this.options.layers.length; i++) {\n var layer = this.options.layers[i];\n this.get(layer, {}, this._layerMetadataCallback(layer));\n }\n }\n});\n\nexport function mapServiceProvider (options) {\n return new MapServiceProvider(options);\n}\n\nexport default mapServiceProvider;\n","import { GeocodeService } from '../Services/Geocode';\n\nexport var GeocodeServiceProvider = GeocodeService.extend({\n options: {\n label: 'Geocode Server',\n maxResults: 5\n },\n\n suggestions: function (text, bounds, callback) {\n\n if (this.options.supportsSuggest) {\n var request = this.suggest().text(text);\n if (bounds) {\n request.within(bounds);\n }\n\n return request.run(function (error, results, response) {\n var suggestions = [];\n if (!error) {\n while (response.suggestions.length && suggestions.length <= (this.options.maxResults - 1)) {\n var suggestion = response.suggestions.shift();\n if (!suggestion.isCollection) {\n suggestions.push({\n text: suggestion.text,\n magicKey: suggestion.magicKey\n });\n }\n }\n }\n callback(error, suggestions);\n }, this);\n } else {\n callback(undefined, []);\n return false;\n }\n },\n\n results: function (text, key, bounds, callback) {\n var request = this.geocode().text(text);\n\n request.maxLocations(this.options.maxResults);\n\n if (bounds) {\n request.within(bounds);\n }\n\n return request.run(function (error, response) {\n callback(error, response.results);\n }, this);\n }\n});\n\nexport function geocodeServiceProvider (options) {\n return new GeocodeServiceProvider(options);\n}\n\nexport default geocodeServiceProvider;\n","export var VERSION = '2.0.0-beta.3';\nexport var WorldGeocodingServiceUrl = (window.location.protocol === 'https:' ? 'https:' : 'http:') + '//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/';\n\n// import tasks\nexport { Geocode, geocode } from './Tasks/Geocode';\nexport { ReverseGeocode, reverseGeocode } from './Tasks/ReverseGeocode';\nexport { Suggest, suggest } from './Tasks/Suggest';\n\n// import service\nexport { GeocodeService, geocodeService } from './Services/Geocode';\n\n// import control\nexport { Geosearch, geosearch } from './Controls/Geosearch';\n\n// import providers\nexport { ArcgisOnlineProvider, arcgisOnlineProvider } from './Providers/ArcgisOnlineGeocoder';\nexport { FeatureLayerProvider, featureLayerProvider} from './Providers/FeatureLayer';\nexport { MapServiceProvider, mapServiceProvider} from './Providers/MapService';\nexport { GeocodeServiceProvider, geocodeServiceProvider} from './Providers/GeocodeService';\n"]} \ No newline at end of file diff --git a/dist/img/loading.gif b/dist/img/loading.gif new file mode 100755 index 0000000..d123f88 Binary files /dev/null and b/dist/img/loading.gif differ diff --git a/dist/img/loading@2x.gif b/dist/img/loading@2x.gif new file mode 100755 index 0000000..ceec3a1 Binary files /dev/null and b/dist/img/loading@2x.gif differ diff --git a/dist/img/search.png b/dist/img/search.png new file mode 100644 index 0000000..0d01c45 Binary files /dev/null and b/dist/img/search.png differ diff --git a/dist/img/search@2x.png b/dist/img/search@2x.png new file mode 100644 index 0000000..5e96a8b Binary files /dev/null and b/dist/img/search@2x.png differ