{"version":3,"file":"esri-leaflet-geocoder.js","sources":["../package.json","../src/Tasks/Geocode.js","../src/Tasks/ReverseGeocode.js","../src/Tasks/Suggest.js","../src/Services/Geocode.js","../src/Classes/GeosearchCore.js","../src/Providers/ArcgisOnlineGeocoder.js","../src/Controls/Geosearch.js","../src/Providers/FeatureLayer.js","../src/Providers/MapService.js","../src/Providers/GeocodeService.js","../src/EsriLeafletGeocoding.js"],"sourcesContent":["{\n  \"name\": \"esri-leaflet-geocoder\",\n  \"description\": \"Esri Geocoding utility and search plugin for Leaflet.\",\n  \"version\": \"2.2.9\",\n  \"author\": \"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)\",\n  \"contributors\": [\n    \"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)\",\n    \"John Gravois <jgravois@esri.com> (http://johngravois.com)\"\n  ],\n  \"dependencies\": {\n    \"esri-leaflet\": \"^2.0.3\",\n    \"leaflet\": \"^1.0.0\"\n  },\n  \"devDependencies\": {\n    \"chai\": \"3.5.0\",\n    \"gh-release\": \"^2.0.0\",\n    \"http-server\": \"^0.10.0\",\n    \"imagemin\": \"^3.2.0\",\n    \"isparta\": \"^4.0.0\",\n    \"istanbul\": \"^0.4.2\",\n    \"karma\": \"^1.3.0\",\n    \"karma-chai-sinon\": \"^0.1.3\",\n    \"karma-chrome-launcher\": \"^2.2.0\",\n    \"karma-coverage\": \"^1.1.1\",\n    \"karma-mocha\": \"^1.3.0\",\n    \"karma-mocha-reporter\": \"^2.2.1\",\n    \"karma-sourcemap-loader\": \"^0.3.5\",\n    \"mkdirp\": \"^0.5.1\",\n    \"mocha\": \"^3.1.0\",\n    \"node-sass\": \"^3.2.0\",\n    \"parallelshell\": \"^2.0.0\",\n    \"phantomjs\": \"^1.9.8\",\n    \"rollup\": \"^0.25.4\",\n    \"rollup-plugin-json\": \"^2.0.0\",\n    \"rollup-plugin-node-resolve\": \"^1.4.0\",\n    \"rollup-plugin-uglify\": \"^0.3.1\",\n    \"semistandard\": \"^9.0.0\",\n    \"sinon\": \"^1.11.1\",\n    \"sinon-chai\": \"2.8.0\",\n    \"snazzy\": \"^5.0.0\",\n    \"uglify-js\": \"^2.6.1\",\n    \"watch\": \"^0.17.1\"\n  },\n  \"homepage\": \"https://github.com/Esri/esri-leaflet-geocoder\",\n  \"jsnext:main\": \"src/EsriLeafletGeocoding.js\",\n  \"jspm\": {\n    \"registry\": \"npm\",\n    \"format\": \"es6\",\n    \"main\": \"src/EsriLeafletGeocoding.js\"\n  },\n  \"license\": \"Apache-2.0\",\n  \"main\": \"dist/esri-leaflet-geocoder-debug.js\",\n  \"browser\": \"dist/esri-leaflet-geocoder-debug.js\",\n  \"readmeFilename\": \"README.md\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git@github.com:Esri/esri-leaflet-geocoder.git\"\n  },\n  \"scripts\": {\n    \"prebuild\": \"mkdirp dist\",\n    \"build\": \"rollup -c profiles/debug.js & rollup -c profiles/production.js & npm run css & npm run img\",\n    \"css\": \"node-sass ./src/esri-leaflet-geocoder.css ./dist/esri-leaflet-geocoder.css --output-style compressed\",\n    \"img\": \"imagemin ./src/img ./dist/img\",\n    \"lint\": \"semistandard | snazzy\",\n    \"prepare\": \"npm run build\",\n    \"pretest\": \"npm run build\",\n    \"release\": \"./scripts/release.sh\",\n    \"start-watch\": \"watch \\\"npm run build\\\" src\",\n    \"start\": \"parallelshell \\\"npm run start-watch\\\" \\\"http-server -p 5678 -c-1 -o\\\"\",\n    \"test\": \"npm run lint && karma start\"\n  },\n  \"semistandard\": {\n    \"globals\": [\n      \"expect\",\n      \"L\",\n      \"XMLHttpRequest\",\n      \"sinon\",\n      \"xhr\"\n    ]\n  },\n  \"style\": \"./dist/esri-leaflet-geocoder.css\"\n}\n","import {\n  latLng,\n  latLngBounds\n} from 'leaflet';\nimport { Task, Util as EsriUtil } from 'esri-leaflet';\nimport { WorldGeocodingServiceUrl } from '../EsriLeafletGeocoding';\n\nexport var Geocode = Task.extend({\n  path: 'findAddressCandidates',\n\n  params: {\n    outSr: 4326,\n    forStorage: false,\n    outFields: '*',\n    maxLocations: 20\n  },\n\n  setters: {\n    'address': 'address',\n    'neighborhood': 'neighborhood',\n    'city': 'city',\n    'subregion': 'subregion',\n    'region': 'region',\n    'postal': 'postal',\n    'country': 'country',\n    'text': 'singleLine',\n    'category': 'category',\n    'token': 'token',\n    'key': 'magicKey',\n    'fields': 'outFields',\n    'forStorage': 'forStorage',\n    'maxLocations': 'maxLocations'\n  },\n\n  initialize: function (options) {\n    options = options || {};\n    options.url = options.url || WorldGeocodingServiceUrl;\n    Task.prototype.initialize.call(this, options);\n  },\n\n  within: function (bounds) {\n    bounds = latLngBounds(bounds);\n    this.params.searchExtent = EsriUtil.boundsToExtent(bounds);\n    return this;\n  },\n\n  nearby: function (coords, radius) {\n    var centroid = latLng(coords);\n    this.params.location = centroid.lng + ',' + centroid.lat;\n    this.params.distance = Math.min(Math.max(radius, 2000), 50000);\n    return this;\n  },\n\n  run: function (callback, context) {\n    if (this.options.customParam) {\n      this.params[this.options.customParam] = this.params.singleLine;\n      delete this.params.singleLine;\n    }\n\n    return this.request(function (error, response) {\n      var processor = this._processGeocoderResponse;\n      var results = (!error) ? processor(response) : undefined;\n      callback.call(context, error, { results: results }, response);\n    }, this);\n  },\n\n  _processGeocoderResponse: function (response) {\n    var results = [];\n\n    for (var i = 0; i < response.candidates.length; i++) {\n      var candidate = response.candidates[i];\n      if (candidate.extent) {\n        var bounds = EsriUtil.extentToBounds(candidate.extent);\n      }\n\n      results.push({\n        text: candidate.address,\n        bounds: bounds,\n        score: candidate.score,\n        latlng: latLng(candidate.location.y, candidate.location.x),\n        properties: candidate.attributes\n      });\n    }\n    return results;\n  }\n});\n\nexport function geocode (options) {\n  return new Geocode(options);\n}\n\nexport default geocode;\n","import { latLng } from 'leaflet';\nimport { Task } from 'esri-leaflet';\nimport { WorldGeocodingServiceUrl } from '../EsriLeafletGeocoding';\n\nexport var ReverseGeocode = Task.extend({\n  path: 'reverseGeocode',\n\n  params: {\n    outSR: 4326,\n    returnIntersection: false\n  },\n\n  setters: {\n    'distance': 'distance',\n    'language': 'langCode',\n    'intersection': 'returnIntersection'\n  },\n\n  initialize: function (options) {\n    options = options || {};\n    options.url = options.url || WorldGeocodingServiceUrl;\n    Task.prototype.initialize.call(this, options);\n  },\n\n  latlng: function (coords) {\n    var centroid = latLng(coords);\n    this.params.location = centroid.lng + ',' + centroid.lat;\n    return this;\n  },\n\n  run: function (callback, context) {\n    return this.request(function (error, response) {\n      var result;\n\n      if (!error) {\n        result = {\n          latlng: latLng(response.location.y, response.location.x),\n          address: response.address\n        };\n      } else {\n        result = undefined;\n      }\n\n      callback.call(context, error, result, response);\n    }, this);\n  }\n});\n\nexport function reverseGeocode (options) {\n  return new ReverseGeocode(options);\n}\n\nexport default reverseGeocode;\n","import {\n  latLng,\n  latLngBounds\n} from 'leaflet';\nimport { Task, Util as EsriUtil } from 'esri-leaflet';\nimport { WorldGeocodingServiceUrl } from '../EsriLeafletGeocoding';\n\nexport var Suggest = Task.extend({\n  path: 'suggest',\n\n  params: {},\n\n  setters: {\n    text: 'text',\n    category: 'category',\n    countries: 'countryCode',\n    maxSuggestions: 'maxSuggestions'\n  },\n\n  initialize: function (options) {\n    options = options || {};\n    if (!options.url) {\n      options.url = WorldGeocodingServiceUrl;\n      options.supportsSuggest = true;\n    }\n    Task.prototype.initialize.call(this, options);\n  },\n\n  within: function (bounds) {\n    bounds = latLngBounds(bounds);\n    bounds = bounds.pad(0.5);\n    var center = bounds.getCenter();\n    var ne = bounds.getNorthWest();\n    this.params.location = center.lng + ',' + center.lat;\n    this.params.distance = Math.min(Math.max(center.distanceTo(ne), 2000), 50000);\n    this.params.searchExtent = EsriUtil.boundsToExtent(bounds);\n    return this;\n  },\n\n  nearby: function (coords, radius) {\n    var centroid = latLng(coords);\n    this.params.location = centroid.lng + ',' + centroid.lat;\n    this.params.distance = Math.min(Math.max(radius, 2000), 50000);\n    return this;\n  },\n\n  run: function (callback, context) {\n    if (this.options.supportsSuggest) {\n      return this.request(function (error, response) {\n        callback.call(context, error, response, response);\n      }, this);\n    } else {\n      console.warn('this geocoding service does not support asking for suggestions');\n    }\n  }\n\n});\n\nexport function suggest (options) {\n  return new Suggest(options);\n}\n\nexport default suggest;\n","import { Service } from 'esri-leaflet';\nimport { WorldGeocodingServiceUrl } from '../EsriLeafletGeocoding';\nimport geocode from '../Tasks/Geocode';\nimport reverseGeocode from '../Tasks/ReverseGeocode';\nimport suggest from '../Tasks/Suggest';\n\nexport var GeocodeService = Service.extend({\n  initialize: function (options) {\n    options = options || {};\n    if (options.url) {\n      Service.prototype.initialize.call(this, options);\n      this._confirmSuggestSupport();\n    } else {\n      options.url = WorldGeocodingServiceUrl;\n      options.supportsSuggest = true;\n      Service.prototype.initialize.call(this, options);\n    }\n  },\n\n  geocode: function () {\n    return geocode(this);\n  },\n\n  reverse: function () {\n    return reverseGeocode(this);\n  },\n\n  suggest: function () {\n    // requires either the Esri World Geocoding Service or a <10.3 ArcGIS Server Geocoding Service that supports suggest.\n    return suggest(this);\n  },\n\n  _confirmSuggestSupport: function () {\n    this.metadata(function (error, response) {\n      if (error) { return; }\n      // pre 10.3 geocoding services dont list capabilities (and dont support maxLocations)\n      // only SOME individual services have been configured to support asking for suggestions\n      if (!response.capabilities) {\n        this.options.supportsSuggest = false;\n      } else if (response.capabilities.indexOf('Suggest') > -1) {\n        this.options.supportsSuggest = true;\n      } else {\n        this.options.supportsSuggest = false;\n      }\n      // whether the service supports suggest or not, utilize the metadata response to determine the appropriate parameter name for single line geocoding requests\n      this.options.customParam = response.singleLineAddressField.name;\n    }, this);\n  }\n});\n\nexport function geocodeService (options) {\n  return new GeocodeService(options);\n}\n\nexport default geocodeService;\n","import { Evented, Util, latLngBounds } from 'leaflet';\n\nexport var GeosearchCore = Evented.extend({\n\n  options: {\n    zoomToResult: true,\n    useMapBounds: 12,\n    searchBounds: null\n  },\n\n  initialize: function (control, options) {\n    Util.setOptions(this, options);\n    this._control = control;\n\n    if (!options || !options.providers || !options.providers.length) {\n      throw new Error('You must specify at least one provider');\n    }\n\n    this._providers = options.providers;\n  },\n\n  _geocode: function (text, key, provider) {\n    var activeRequests = 0;\n    var allResults = [];\n    var bounds;\n\n    var callback = Util.bind(function (error, results) {\n      activeRequests--;\n      if (error) {\n        return;\n      }\n\n      if (results) {\n        allResults = allResults.concat(results);\n      }\n\n      if (activeRequests <= 0) {\n        bounds = this._boundsFromResults(allResults);\n\n        this.fire('results', {\n          results: allResults,\n          bounds: bounds,\n          latlng: (bounds) ? bounds.getCenter() : undefined,\n          text: text\n        }, true);\n\n        if (this.options.zoomToResult && bounds) {\n          this._control._map.fitBounds(bounds);\n        }\n\n        this.fire('load');\n      }\n    }, this);\n\n    if (key) {\n      activeRequests++;\n      provider.results(text, key, this._searchBounds(), callback);\n    } else {\n      for (var i = 0; i < this._providers.length; i++) {\n        activeRequests++;\n        this._providers[i].results(text, key, this._searchBounds(), callback);\n      }\n    }\n  },\n\n  _suggest: function (text) {\n    var activeRequests = this._providers.length;\n\n    var createCallback = Util.bind(function (text, provider) {\n      return Util.bind(function (error, suggestions) {\n        if (error) { return; }\n\n        var i;\n\n        activeRequests = activeRequests - 1;\n\n        if (text.length < 2) {\n          this._suggestions.innerHTML = '';\n          this._suggestions.style.display = 'none';\n          return;\n        }\n\n        if (suggestions.length) {\n          for (i = 0; i < suggestions.length; i++) {\n            suggestions[i].provider = provider;\n          }\n        } else {\n          // we still need to update the UI\n          this._control._renderSuggestions(suggestions);\n        }\n\n        if (provider._lastRender !== text && provider.nodes) {\n          for (i = 0; i < provider.nodes.length; i++) {\n            if (provider.nodes[i].parentElement) {\n              this._control._suggestions.removeChild(provider.nodes[i]);\n            }\n          }\n\n          provider.nodes = [];\n        }\n\n        if (suggestions.length && this._control._input.value === text) {\n          this._control.clearSuggestions(provider.nodes);\n\n          provider._lastRender = text;\n          provider.nodes = this._control._renderSuggestions(suggestions);\n          this._control._nodes = [];\n        }\n      }, this);\n    }, this);\n\n    this._pendingSuggestions = [];\n\n    for (var i = 0; i < this._providers.length; i++) {\n      var provider = this._providers[i];\n      var request = provider.suggestions(text, this._searchBounds(), createCallback(text, provider));\n      this._pendingSuggestions.push(request);\n    }\n  },\n\n  _searchBounds: function () {\n    if (this.options.searchBounds !== null) {\n      return this.options.searchBounds;\n    }\n\n    if (this.options.useMapBounds === false) {\n      return null;\n    }\n\n    if (this.options.useMapBounds === true) {\n      return this._control._map.getBounds();\n    }\n\n    if (this.options.useMapBounds <= this._control._map.getZoom()) {\n      return this._control._map.getBounds();\n    }\n\n    return null;\n  },\n\n  _boundsFromResults: function (results) {\n    if (!results.length) {\n      return;\n    }\n\n    var nullIsland = 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 = 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[j]);\n    }\n\n    return bounds;\n  },\n\n  _getAttribution: function () {\n    var attribs = [];\n    var providers = this._providers;\n\n    for (var i = 0; i < providers.length; i++) {\n      if (providers[i].options.attribution) {\n        attribs.push(providers[i].options.attribution);\n      }\n    }\n\n    return attribs.join(', ');\n  }\n\n});\n\nexport function geosearchCore (control, options) {\n  return new GeosearchCore(control, options);\n}\n\nexport default geosearchCore;\n","import { GeocodeService } from '../Services/Geocode';\n\nexport var ArcgisOnlineProvider = GeocodeService.extend({\n  options: {\n    label: 'Places and Addresses',\n    maxResults: 5\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    // 15 is the maximum number of suggestions that can be returned\n    request.maxSuggestions(this.options.maxResults);\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              unformattedText: 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    }\n    // in the future Address/StreetName geocoding requests that include a magicKey will always only return one match\n    request.maxLocations(this.options.maxResults);\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 {\n  Control,\n  DomEvent,\n  DomUtil,\n  Evented,\n  Util,\n  latLngBounds\n} from 'leaflet';\nimport { geosearchCore } from '../Classes/GeosearchCore';\nimport { arcgisOnlineProvider } from '../Providers/ArcgisOnlineGeocoder';\nimport { Util as EsriUtil } from 'esri-leaflet';\n\nexport var Geosearch = Control.extend({\n  includes: Evented.prototype,\n\n  options: {\n    position: 'topleft',\n    collapseAfterResult: true,\n    expanded: false,\n    allowMultipleResults: true,\n    placeholder: 'Search for places or addresses',\n    title: 'Location Search'\n  },\n\n  initialize: function (options) {\n    Util.setOptions(this, options);\n\n    if (!options || !options.providers || !options.providers.length) {\n      if (!options) {\n        options = {};\n      }\n      options.providers = [ arcgisOnlineProvider() ];\n    }\n\n    // instantiate the underlying class and pass along options\n    this._geosearchCore = geosearchCore(this, options);\n    this._geosearchCore._providers = options.providers;\n\n    // bubble each providers events to the control\n    this._geosearchCore.addEventParent(this);\n    for (var i = 0; i < this._geosearchCore._providers.length; i++) {\n      this._geosearchCore._providers[i].addEventParent(this);\n    }\n\n    this._geosearchCore._pendingSuggestions = [];\n\n    Control.prototype.initialize.call(options);\n  },\n\n  _renderSuggestions: function (suggestions) {\n    var currentGroup;\n\n    if (suggestions.length > 0) {\n      this._suggestions.style.display = 'block';\n    }\n    // set the maxHeight of the suggestions box to\n    // map height\n    // - suggestions offset (distance from top of suggestions to top of control)\n    // - control offset (distance from top of control to top of map)\n    // - 10 (extra padding)\n    this._suggestions.style.maxHeight = (this._map.getSize().y - this._suggestions.offsetTop - this._wrapper.offsetTop - 10) + 'px';\n\n    var nodes = [];\n    var list;\n    var header;\n    var suggestionTextArray = [];\n\n    for (var i = 0; i < suggestions.length; i++) {\n      var suggestion = suggestions[i];\n      if (!header && this._geosearchCore._providers.length > 1 && currentGroup !== suggestion.provider.options.label) {\n        header = 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 = DomUtil.create('ul', 'geocoder-control-list', this._suggestions);\n      }\n\n      if (suggestionTextArray.indexOf(suggestion.text) === -1) {\n        var suggestionItem = 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        suggestionItem.unformattedText = suggestion.unformattedText;\n      } else {\n        for (var j = 0; j < list.childNodes.length; j++) {\n          // if the same text already appears in the list of suggestions, append an additional ObjectID to its magicKey instead\n          if (list.childNodes[j].innerHTML === suggestion.text) {\n            list.childNodes[j]['data-magic-key'] += ',' + suggestion.magicKey;\n          }\n        }\n      }\n      suggestionTextArray.push(suggestion.text);\n    }\n\n    DomUtil.removeClass(this._input, 'geocoder-control-loading');\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 = 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 = 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[j]);\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      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  clearSuggestions: function () {\n    if (this._nodes) {\n      for (var k = 0; k < this._nodes.length; k++) {\n        if (this._nodes[k].parentElement) {\n          this._suggestions.removeChild(this._nodes[k]);\n        }\n      }\n    }\n  },\n\n  _setupClick: function () {\n    DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n    this._input.focus();\n  },\n\n  disable: function () {\n    this._input.disabled = true;\n    DomUtil.addClass(this._input, 'geocoder-control-input-disabled');\n    DomEvent.removeListener(this._wrapper, 'click', this._setupClick, this);\n  },\n\n  enable: function () {\n    this._input.disabled = false;\n    DomUtil.removeClass(this._input, 'geocoder-control-input-disabled');\n    DomEvent.addListener(this._wrapper, 'click', this._setupClick, this);\n  },\n\n  getAttribution: function () {\n    var attribs = [];\n\n    for (var i = 0; i < this._providers.length; i++) {\n      if (this._providers[i].options.attribution) {\n        attribs.push(this._providers[i].options.attribution);\n      }\n    }\n\n    return attribs.join(', ');\n  },\n\n  geocodeSuggestion: function (e) {\n    var suggestionItem = e.target || e.srcElement;\n\n    // make sure and point at the actual 'geocoder-control-suggestion'\n    if (suggestionItem.classList.length < 1) {\n      suggestionItem = suggestionItem.parentNode;\n    }\n\n    this._geosearchCore._geocode(suggestionItem.unformattedText, suggestionItem['data-magic-key'], suggestionItem.provider);\n    this.clear();\n  },\n\n  onAdd: function (map) {\n    // include 'Powered by Esri' in map attribution\n    EsriUtil.setEsriAttribution(map);\n\n    this._map = map;\n    this._wrapper = DomUtil.create('div', 'geocoder-control');\n    this._input = DomUtil.create('input', 'geocoder-control-input leaflet-bar', this._wrapper);\n    this._input.title = this.options.title;\n\n    if (this.options.expanded) {\n      DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n      this._input.placeholder = this.options.placeholder;\n    }\n\n    this._suggestions = DomUtil.create('div', 'geocoder-control-suggestions leaflet-bar', this._wrapper);\n\n    var credits = this._geosearchCore._getAttribution();\n    map.attributionControl.addAttribution(credits);\n\n    DomEvent.addListener(this._input, 'focus', function (e) {\n      this._input.placeholder = this.options.placeholder;\n      DomUtil.addClass(this._wrapper, 'geocoder-control-expanded');\n    }, this);\n\n    DomEvent.addListener(this._wrapper, 'click', this._setupClick, this);\n\n    // make sure both click and touch spawn an address/poi search\n    DomEvent.addListener(this._suggestions, 'mousedown', this.geocodeSuggestion, this);\n    DomEvent.addListener(this._suggestions, 'touchend', this.geocodeSuggestion, this);\n\n    DomEvent.addListener(this._input, 'blur', function (e) {\n      this.clear();\n    }, this);\n\n    DomEvent.addListener(this._input, 'keydown', function (e) {\n      var text = (e.target || e.srcElement).value;\n\n      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          /*\n            if an item has been selected, geocode it\n            if focus is on the input textbox, geocode only if multiple results are allowed and more than two characters are present, or if a single suggestion is displayed.\n            if less than two characters have been typed, abort the geocode\n          */\n          if (selected) {\n            this._geosearchCore._geocode(selected.unformattedText, selected['data-magic-key'], selected.provider);\n            this.clear();\n          } else if (this.options.allowMultipleResults && text.length >= 2) {\n            this._geosearchCore._geocode(this._input.value, undefined);\n            this.clear();\n          } else {\n            if (list.length === 1) {\n              DomUtil.addClass(list[0], 'geocoder-control-selected');\n              this._geosearchCore._geocode(list[0].innerHTML, list[0]['data-magic-key'], list[0].provider);\n            } else {\n              this.clear();\n              this._input.blur();\n            }\n          }\n          DomEvent.preventDefault(e);\n          break;\n        case 38:\n          if (selected) {\n            DomUtil.removeClass(selected, 'geocoder-control-selected');\n          }\n\n          var previousItem = list[selectedPosition - 1];\n\n          if (selected && previousItem) {\n            DomUtil.addClass(previousItem, 'geocoder-control-selected');\n          } else {\n            DomUtil.addClass(list[list.length - 1], 'geocoder-control-selected');\n          }\n          DomEvent.preventDefault(e);\n          break;\n        case 40:\n          if (selected) {\n            DomUtil.removeClass(selected, 'geocoder-control-selected');\n          }\n\n          var nextItem = list[selectedPosition + 1];\n\n          if (selected && nextItem) {\n            DomUtil.addClass(nextItem, 'geocoder-control-selected');\n          } else {\n            DomUtil.addClass(list[0], 'geocoder-control-selected');\n          }\n          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._geosearchCore._pendingSuggestions.length; x++) {\n            var request = this._geosearchCore._pendingSuggestions[x];\n            if (request && request.abort && !request.id) {\n              request.abort();\n            }\n          }\n          break;\n      }\n    }, this);\n\n    DomEvent.addListener(this._input, 'keyup', 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        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          DomUtil.addClass(this._input, 'geocoder-control-loading');\n          this._geosearchCore._suggest(text);\n        }\n      }\n    }, 50, this), this);\n\n    DomEvent.disableClickPropagation(this._wrapper);\n\n    // when mouse moves over suggestions disable scroll wheel zoom if its enabled\n    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    DomEvent.addListener(this._suggestions, 'mouseout', function (e) {\n      if (!map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) {\n        map.scrollWheelZoom.enable();\n      }\n    });\n\n    this._geosearchCore.on('load', function (e) {\n      DomUtil.removeClass(this._input, 'geocoder-control-loading');\n      this.clear();\n      this._input.blur();\n    }, this);\n\n    return this._wrapper;\n  }\n});\n\nexport function geosearch (options) {\n  return new Geosearch(options);\n}\n\nexport default geosearch;\n","import { Util, geoJson, latLngBounds } 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    this._suggestionsQuery = this.query();\n    this._resultsQuery = this.query();\n  },\n\n  suggestions: function (text, bounds, callback) {\n    var query = this._suggestionsQuery.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        for (var i = results.features.length - 1; i >= 0; i--) {\n          var feature = results.features[i];\n          suggestions.push({\n            text: this.options.formatSuggestion.call(this, feature),\n            unformattedText: feature.properties[this.options.searchFields[0]],\n            magicKey: feature.id\n          });\n        }\n        callback(error, suggestions.slice(0, this.options.maxResults));\n      }\n    }, this);\n\n    return request;\n  },\n\n  results: function (text, key, bounds, callback) {\n    var query = this._resultsQuery;\n\n    if (key) {\n      delete query.params.where;\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(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          // clear query parameters for the next search\n          delete this._resultsQuery.params['objectIds'];\n        }\n      }\n      callback(error, results);\n    }, this));\n  },\n\n  orderBy: function (fieldName, order) {\n    this._suggestionsQuery.orderBy(fieldName, order);\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    if (this.options.where) {\n      return this.options.where + ' AND (' + queryString.join(' OR ') + ')';\n    } else {\n      return queryString.join(' OR ');\n    }\n  },\n\n  _featureBounds: function (feature) {\n    var geojson = 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 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 { Util, geoJson, latLngBounds } 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] + ' <small>' + feature.layerName + '</small>';\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              unformattedText: feature.properties[feature.displayFieldName],\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).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 || response.results[i].layerId;\n\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 = 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 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 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    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                unformattedText: 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    if (key) {\n      request.key(key);\n    }\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 { version as VERSION } from '../package.json';\nexport var WorldGeocodingServiceUrl = 'https://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 supporting class\nexport { GeosearchCore, geosearchCore } from './Classes/GeosearchCore';\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"],"names":["geocode","options","Geocode","reverseGeocode","ReverseGeocode","suggest","Suggest","geocodeService","GeocodeService","geosearchCore","control","GeosearchCore","arcgisOnlineProvider","ArcgisOnlineProvider","geosearch","Geosearch","featureLayerProvider","FeatureLayerProvider","mapServiceProvider","MapServiceProvider","geocodeServiceProvider","GeocodeServiceProvider","Task","extend","path","params","outSr","forStorage","outFields","maxLocations","setters","address","neighborhood","city","subregion","region","postal","country","text","category","token","key","fields","initialize","url","WorldGeocodingServiceUrl","prototype","call","this","within","bounds","latLngBounds","searchExtent","EsriUtil","boundsToExtent","nearby","coords","radius","centroid","latLng","location","lng","lat","distance","Math","min","max","run","callback","context","customParam","singleLine","request","error","response","processor","_processGeocoderResponse","results","undefined","i","candidates","length","candidate","extent","extentToBounds","push","score","latlng","y","x","properties","attributes","outSR","returnIntersection","language","intersection","result","countries","maxSuggestions","supportsSuggest","pad","center","getCenter","ne","getNorthWest","distanceTo","console","warn","Service","_confirmSuggestSupport","reverse","metadata","capabilities","indexOf","singleLineAddressField","name","Evented","zoomToResult","useMapBounds","searchBounds","Util","setOptions","_control","providers","Error","_providers","_geocode","provider","activeRequests","allResults","bind","concat","_boundsFromResults","fire","_map","fitBounds","_searchBounds","_suggest","createCallback","suggestions","_suggestions","innerHTML","style","display","_renderSuggestions","_lastRender","nodes","parentElement","removeChild","_input","value","clearSuggestions","_nodes","_pendingSuggestions","getBounds","getZoom","nullIsland","resultBounds","resultLatlngs","isValid","equals","j","_getAttribution","attribs","attribution","join","label","maxResults","categories","suggestion","shift","isCollection","unformattedText","magicKey","Control","includes","position","collapseAfterResult","expanded","allowMultipleResults","placeholder","title","_geosearchCore","addEventParent","currentGroup","maxHeight","getSize","offsetTop","_wrapper","list","header","suggestionTextArray","DomUtil","create","textContent","innerText","suggestionItem","childNodes","removeClass","clear","scrollWheelZoom","enabled","enable","k","_setupClick","addClass","focus","disable","disabled","DomEvent","removeListener","addListener","getAttribution","geocodeSuggestion","e","target","srcElement","classList","parentNode","onAdd","map","setEsriAttribution","credits","attributionControl","addAttribution","selectedPosition","querySelectorAll","selected","keyCode","blur","preventDefault","previousItem","nextItem","abort","id","throttle","which","_lastValue","disableClickPropagation","on","FeatureLayerService","bufferRadius","formatSuggestion","feature","searchFields","_suggestionsQuery","query","_resultsQuery","where","_buildQuery","returnGeometry","intersects","idField","raw","objectIdFieldName","features","slice","featureIds","_featureBounds","geojson","orderBy","fieldName","order","queryString","field","geoJson","geometry","type","lngRadius","cos","PI","latRadius","MapService","layers","displayFieldName","layerName","_getIdFields","find","count","layer","layerId","_idFields","_layerNames","_displayFields","featureId","split","_layerMetadataCallback","layerid","displayField","get"],"mappings":";;;+UCuFO,SAASA,GAASC,GACvB,MAAO,IAAIC,GAAQD,GCxCd,QAASE,GAAgBF,GAC9B,MAAO,IAAIG,GAAeH,GCSrB,QAASI,GAASJ,GACvB,MAAO,IAAIK,GAAQL,GCTd,QAASM,GAAgBN,GAC9B,MAAO,IAAIO,GAAeP,GCwIrB,QAASQ,GAAeC,EAAST,GACtC,MAAO,IAAIU,GAAcD,EAAST,GCzH7B,QAASW,GAAsBX,GACpC,MAAO,IAAIY,GAAqBZ,GCiT3B,QAASa,GAAWb,GACzB,MAAO,IAAIc,GAAUd,GCvPhB,QAASe,GAAsBf,GACpC,MAAO,IAAIgB,GAAqBhB,GCC3B,QAASiB,GAAoBjB,GAClC,MAAO,IAAIkB,GAAmBlB,GC1EzB,QAASmB,GAAwBnB,GACtC,MAAO,IAAIoB,GAAuBpB,MTlDzBC,GAAUoB,OAAKC,QACxBC,KAAM,wBAENC,QACEC,MAAO,KACPC,YAAY,EACZC,UAAW,IACXC,aAAc,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