diff --git a/dist/esri-leaflet-geocoder-debug.js b/dist/esri-leaflet-geocoder-debug.js new file mode 100644 index 0000000..0678e48 --- /dev/null +++ b/dist/esri-leaflet-geocoder-debug.js @@ -0,0 +1,1227 @@ +/* esri-leaflet-geocoder - v2.2.14 - Mon Mar 11 2019 11:22:02 GMT-0700 (Pacific Daylight Time) + * Copyright (c) 2019 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 = global.L || {}, global.L.esri = global.L.esri || {}, global.L.esri.Geocoding = {}),global.L,global.L.esri)); +}(this, (function (exports,leaflet,esriLeaflet) { 'use strict'; + +var version = "2.2.14"; + +var WorldGeocodingServiceUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/'; + +var Geocode = esriLeaflet.Task.extend({ + path: 'findAddressCandidates', + + params: { + outSr: 4326, + forStorage: false, + outFields: '*', + maxLocations: 20 + }, + + setters: { + 'address': 'address', + 'neighborhood': 'neighborhood', + 'city': 'city', + 'subregion': 'subregion', + 'region': 'region', + 'postal': 'postal', + 'country': 'country', + 'text': 'singleLine', + 'category': 'category', + 'token': 'token', + 'key': 'magicKey', + 'fields': 'outFields', + 'forStorage': 'forStorage', + 'maxLocations': 'maxLocations', + // World Geocoding Service (only works with singleLine) + 'countries': 'sourceCountry' + }, + + initialize: function (options) { + options = options || {}; + options.url = options.url || WorldGeocodingServiceUrl; + esriLeaflet.Task.prototype.initialize.call(this, options); + }, + + within: function (bounds) { + bounds = leaflet.latLngBounds(bounds); + this.params.searchExtent = esriLeaflet.Util.boundsToExtent(bounds); + return this; + }, + + nearby: function (coords, radius) { + var centroid = leaflet.latLng(coords); + this.params.location = centroid.lng + ',' + centroid.lat; + this.params.distance = Math.min(Math.max(radius, 2000), 50000); + return this; + }, + + run: function (callback, context) { + if (this.options.customParam) { + this.params[this.options.customParam] = this.params.singleLine; + delete this.params.singleLine; + } + + return this.request(function (error, response) { + var processor = this._processGeocoderResponse; + var results = (!error) ? processor(response) : undefined; + callback.call(context, error, { results: results }, response); + }, this); + }, + + _processGeocoderResponse: function (response) { + var results = []; + + for (var i = 0; i < response.candidates.length; i++) { + var candidate = response.candidates[i]; + if (candidate.extent) { + var bounds = esriLeaflet.Util.extentToBounds(candidate.extent); + } + + results.push({ + text: candidate.address, + bounds: bounds, + score: candidate.score, + latlng: leaflet.latLng(candidate.location.y, candidate.location.x), + properties: candidate.attributes + }); + } + return results; + } +}); + +function geocode (options) { + return new Geocode(options); +} + +var ReverseGeocode = esriLeaflet.Task.extend({ + path: 'reverseGeocode', + + params: { + outSR: 4326, + returnIntersection: false + }, + + setters: { + 'distance': 'distance', + 'language': 'langCode', + 'intersection': 'returnIntersection' + }, + + initialize: function (options) { + options = options || {}; + options.url = options.url || WorldGeocodingServiceUrl; + esriLeaflet.Task.prototype.initialize.call(this, options); + }, + + latlng: function (coords) { + var centroid = leaflet.latLng(coords); + this.params.location = centroid.lng + ',' + centroid.lat; + return this; + }, + + run: function (callback, context) { + return this.request(function (error, response) { + var result; + + if (!error) { + result = { + latlng: leaflet.latLng(response.location.y, response.location.x), + address: response.address + }; + } else { + result = undefined; + } + + callback.call(context, error, result, response); + }, this); + } +}); + +function reverseGeocode (options) { + return new ReverseGeocode(options); +} + +var Suggest = esriLeaflet.Task.extend({ + path: 'suggest', + + params: {}, + + setters: { + text: 'text', + category: 'category', + countries: 'countryCode', + maxSuggestions: 'maxSuggestions' + }, + + initialize: function (options) { + options = options || {}; + if (!options.url) { + options.url = WorldGeocodingServiceUrl; + options.supportsSuggest = true; + } + esriLeaflet.Task.prototype.initialize.call(this, options); + }, + + within: function (bounds) { + bounds = leaflet.latLngBounds(bounds); + bounds = bounds.pad(0.5); + var center = bounds.getCenter(); + var ne = bounds.getNorthWest(); + this.params.location = center.lng + ',' + center.lat; + this.params.distance = Math.min(Math.max(center.distanceTo(ne), 2000), 50000); + this.params.searchExtent = esriLeaflet.Util.boundsToExtent(bounds); + return this; + }, + + nearby: function (coords, radius) { + var centroid = leaflet.latLng(coords); + this.params.location = centroid.lng + ',' + centroid.lat; + this.params.distance = Math.min(Math.max(radius, 2000), 50000); + return this; + }, + + run: function (callback, context) { + if (this.options.supportsSuggest) { + return this.request(function (error, response) { + callback.call(context, error, response, response); + }, this); + } else { + console.warn('this geocoding service does not support asking for suggestions'); + } + } + +}); + +function suggest (options) { + return new Suggest(options); +} + +var GeocodeService = esriLeaflet.Service.extend({ + initialize: function (options) { + options = options || {}; + if (options.url) { + esriLeaflet.Service.prototype.initialize.call(this, options); + this._confirmSuggestSupport(); + } else { + options.url = WorldGeocodingServiceUrl; + options.supportsSuggest = true; + esriLeaflet.Service.prototype.initialize.call(this, options); + } + }, + + geocode: function () { + return geocode(this); + }, + + reverse: function () { + return reverseGeocode(this); + }, + + suggest: function () { + // requires either the Esri World Geocoding Service or a <10.3 ArcGIS Server Geocoding Service that supports suggest. + return suggest(this); + }, + + _confirmSuggestSupport: function () { + this.metadata(function (error, response) { + if (error) { return; } + // pre 10.3 geocoding services dont list capabilities (and dont support maxLocations) + // only SOME individual services have been configured to support asking for suggestions + if (!response.capabilities) { + this.options.supportsSuggest = false; + } else if (response.capabilities.indexOf('Suggest') > -1) { + this.options.supportsSuggest = true; + } else { + this.options.supportsSuggest = false; + } + // whether the service supports suggest or not, utilize the metadata response to determine the appropriate parameter name for single line geocoding requests + this.options.customParam = response.singleLineAddressField.name; + }, this); + } +}); + +function geocodeService (options) { + return new GeocodeService(options); +} + +var GeosearchCore = leaflet.Evented.extend({ + + options: { + zoomToResult: true, + useMapBounds: 12, + searchBounds: null + }, + + initialize: function (control, options) { + leaflet.Util.setOptions(this, options); + this._control = control; + + if (!options || !options.providers || !options.providers.length) { + throw new Error('You must specify at least one provider'); + } + + this._providers = options.providers; + }, + + _geocode: function (text, key, provider) { + var activeRequests = 0; + var allResults = []; + var bounds; + + var callback = leaflet.Util.bind(function (error, results) { + activeRequests--; + if (error) { + return; + } + + if (results) { + allResults = allResults.concat(results); + } + + if (activeRequests <= 0) { + bounds = this._boundsFromResults(allResults); + + this.fire('results', { + results: allResults, + bounds: bounds, + latlng: (bounds) ? bounds.getCenter() : undefined, + text: text + }, true); + + if (this.options.zoomToResult && bounds) { + this._control._map.fitBounds(bounds); + } + + this.fire('load'); + } + }, this); + + if (key) { + activeRequests++; + provider.results(text, key, this._searchBounds(), callback); + } else { + for (var i = 0; i < this._providers.length; i++) { + activeRequests++; + this._providers[i].results(text, key, this._searchBounds(), callback); + } + } + }, + + _suggest: function (text) { + var activeRequests = this._providers.length; + + var createCallback = leaflet.Util.bind(function (text, provider) { + return leaflet.Util.bind(function (error, suggestions) { + if (error) { return; } + + var i; + + activeRequests = activeRequests - 1; + + if (text.length < 2) { + this._suggestions.innerHTML = ''; + this._suggestions.style.display = 'none'; + return; + } + + if (suggestions.length) { + for (i = 0; i < suggestions.length; i++) { + suggestions[i].provider = provider; + } + } else { + // we still need to update the UI + this._control._renderSuggestions(suggestions); + } + + if (provider._lastRender !== text && provider.nodes) { + for (i = 0; i < provider.nodes.length; i++) { + if (provider.nodes[i].parentElement) { + this._control._suggestions.removeChild(provider.nodes[i]); + } + } + + provider.nodes = []; + } + + if (suggestions.length && this._control._input.value === text) { + this._control.clearSuggestions(provider.nodes); + + provider._lastRender = text; + provider.nodes = this._control._renderSuggestions(suggestions); + this._control._nodes = []; + } + }, this); + }, this); + + this._pendingSuggestions = []; + + for (var i = 0; i < this._providers.length; i++) { + var provider = this._providers[i]; + var request = provider.suggestions(text, this._searchBounds(), createCallback(text, provider)); + this._pendingSuggestions.push(request); + } + }, + + _searchBounds: function () { + if (this.options.searchBounds !== null) { + return this.options.searchBounds; + } + + if (this.options.useMapBounds === false) { + return null; + } + + if (this.options.useMapBounds === true) { + return this._control._map.getBounds(); + } + + if (this.options.useMapBounds <= this._control._map.getZoom()) { + return this._control._map.getBounds(); + } + + return null; + }, + + _boundsFromResults: function (results) { + if (!results.length) { + return; + } + + var nullIsland = leaflet.latLngBounds([0, 0], [0, 0]); + var resultBounds = []; + var resultLatlngs = []; + + // collect the bounds and center of each result + for (var i = results.length - 1; i >= 0; i--) { + var result = results[i]; + + resultLatlngs.push(result.latlng); + + // make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present + if (result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)) { + resultBounds.push(result.bounds); + } + } + + // form a bounds object containing all center points + var bounds = leaflet.latLngBounds(resultLatlngs); + + // and extend it to contain all bounds objects + for (var j = 0; j < resultBounds.length; j++) { + bounds.extend(resultBounds[j]); + } + + return bounds; + }, + + _getAttribution: function () { + var attribs = []; + var providers = this._providers; + + for (var i = 0; i < providers.length; i++) { + if (providers[i].options.attribution) { + attribs.push(providers[i].options.attribution); + } + } + + return attribs.join(', '); + } + +}); + +function geosearchCore (control, options) { + return new GeosearchCore(control, options); +} + +var ArcgisOnlineProvider = GeocodeService.extend({ + options: { + label: 'Places and Addresses', + maxResults: 5 + }, + + 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); + } + + // 15 is the maximum number of suggestions that can be returned + request.maxSuggestions(this.options.maxResults); + + 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, + unformattedText: 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); + } + // in the future Address/StreetName geocoding requests that include a magicKey will always only return one match + request.maxLocations(this.options.maxResults); + + if (bounds) { + request.within(bounds); + } + + if (this.options.forStorage) { + request.forStorage(true); + } + + if (this.options.countries) { + request.countries(this.options.countries); + } + + if (this.options.categories) { + request.category(this.options.categories); + } + + return request.run(function (error, response) { + callback(error, response.results); + }, this); + } +}); + +function arcgisOnlineProvider (options) { + return new ArcgisOnlineProvider(options); +} + +var Geosearch = leaflet.Control.extend({ + includes: leaflet.Evented.prototype, + + options: { + position: 'topleft', + collapseAfterResult: true, + expanded: false, + allowMultipleResults: true, + placeholder: 'Search for places or addresses', + title: 'Location Search' + }, + + initialize: function (options) { + leaflet.Util.setOptions(this, options); + + if (!options || !options.providers || !options.providers.length) { + if (!options) { + options = {}; + } + options.providers = [ arcgisOnlineProvider() ]; + } + + // instantiate the underlying class and pass along options + this._geosearchCore = geosearchCore(this, options); + this._geosearchCore._providers = options.providers; + + // bubble each providers events to the control + this._geosearchCore.addEventParent(this); + for (var i = 0; i < this._geosearchCore._providers.length; i++) { + this._geosearchCore._providers[i].addEventParent(this); + } + + this._geosearchCore._pendingSuggestions = []; + + leaflet.Control.prototype.initialize.call(options); + }, + + _renderSuggestions: function (suggestions) { + var currentGroup; + + if (suggestions.length > 0) { + this._suggestions.style.display = 'block'; + } + // set the maxHeight of the suggestions box to + // map height + // - suggestions offset (distance from top of suggestions to top of control) + // - control offset (distance from top of control to top of map) + // - 10 (extra padding) + this._suggestions.style.maxHeight = (this._map.getSize().y - this._suggestions.offsetTop - this._wrapper.offsetTop - 10) + 'px'; + + var nodes = []; + var list; + var header; + var suggestionTextArray = []; + + for (var i = 0; i < suggestions.length; i++) { + var suggestion = suggestions[i]; + if (!header && this._geosearchCore._providers.length > 1 && currentGroup !== suggestion.provider.options.label) { + header = leaflet.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 = leaflet.DomUtil.create('ul', 'geocoder-control-list', this._suggestions); + } + + if (suggestionTextArray.indexOf(suggestion.text) === -1) { + var suggestionItem = leaflet.DomUtil.create('li', 'geocoder-control-suggestion', list); + + suggestionItem.innerHTML = suggestion.text; + suggestionItem.provider = suggestion.provider; + suggestionItem['data-magic-key'] = suggestion.magicKey; + suggestionItem.unformattedText = suggestion.unformattedText; + } else { + for (var j = 0; j < list.childNodes.length; j++) { + // if the same text already appears in the list of suggestions, append an additional ObjectID to its magicKey instead + if (list.childNodes[j].innerHTML === suggestion.text) { + list.childNodes[j]['data-magic-key'] += ',' + suggestion.magicKey; + } + } + } + suggestionTextArray.push(suggestion.text); + } + + leaflet.DomUtil.removeClass(this._input, 'geocoder-control-loading'); + + nodes.push(list); + + return nodes; + }, + + _boundsFromResults: function (results) { + if (!results.length) { + return; + } + + var nullIsland = leaflet.latLngBounds([0, 0], [0, 0]); + var resultBounds = []; + var resultLatlngs = []; + + // collect the bounds and center of each result + for (var i = results.length - 1; i >= 0; i--) { + var result = results[i]; + + resultLatlngs.push(result.latlng); + + // make sure bounds are valid and not 0,0. sometimes bounds are incorrect or not present + if (result.bounds && result.bounds.isValid() && !result.bounds.equals(nullIsland)) { + resultBounds.push(result.bounds); + } + } + + // form a bounds object containing all center points + var bounds = leaflet.latLngBounds(resultLatlngs); + + // and extend it to contain all bounds objects + for (var j = 0; j < resultBounds.length; j++) { + bounds.extend(resultBounds[j]); + } + + return bounds; + }, + + clear: function () { + this._suggestions.innerHTML = ''; + this._suggestions.style.display = 'none'; + + if (this.options.collapseAfterResult) { + this._input.value = ''; + this._input.placeholder = ''; + leaflet.DomUtil.removeClass(this._wrapper, 'geocoder-control-expanded'); + } + + if (!this._map.scrollWheelZoom.enabled() && this._map.options.scrollWheelZoom) { + this._map.scrollWheelZoom.enable(); + } + }, + + clearSuggestions: function () { + if (this._nodes) { + for (var k = 0; k < this._nodes.length; k++) { + if (this._nodes[k].parentElement) { + this._suggestions.removeChild(this._nodes[k]); + } + } + } + }, + + _setupClick: function () { + leaflet.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded'); + this._input.focus(); + }, + + disable: function () { + this._input.disabled = true; + leaflet.DomUtil.addClass(this._input, 'geocoder-control-input-disabled'); + leaflet.DomEvent.removeListener(this._wrapper, 'click', this._setupClick, this); + }, + + enable: function () { + this._input.disabled = false; + leaflet.DomUtil.removeClass(this._input, 'geocoder-control-input-disabled'); + leaflet.DomEvent.addListener(this._wrapper, 'click', this._setupClick, this); + }, + + getAttribution: function () { + var attribs = []; + + for (var i = 0; i < this._providers.length; i++) { + if (this._providers[i].options.attribution) { + attribs.push(this._providers[i].options.attribution); + } + } + + return attribs.join(', '); + }, + + geocodeSuggestion: function (e) { + var suggestionItem = e.target || e.srcElement; + + // make sure and point at the actual 'geocoder-control-suggestion' + if (suggestionItem.classList.length < 1) { + suggestionItem = suggestionItem.parentNode; + } + + this._geosearchCore._geocode(suggestionItem.unformattedText, suggestionItem['data-magic-key'], suggestionItem.provider); + this.clear(); + }, + + onAdd: function (map) { + // include 'Powered by Esri' in map attribution + esriLeaflet.Util.setEsriAttribution(map); + + this._map = map; + this._wrapper = leaflet.DomUtil.create('div', 'geocoder-control'); + this._input = leaflet.DomUtil.create('input', 'geocoder-control-input leaflet-bar', this._wrapper); + this._input.title = this.options.title; + + if (this.options.expanded) { + leaflet.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded'); + this._input.placeholder = this.options.placeholder; + } + + this._suggestions = leaflet.DomUtil.create('div', 'geocoder-control-suggestions leaflet-bar', this._wrapper); + + var credits = this._geosearchCore._getAttribution(); + + if (map.attributionControl) { + map.attributionControl.addAttribution(credits); + } + + leaflet.DomEvent.addListener(this._input, 'focus', function (e) { + this._input.placeholder = this.options.placeholder; + leaflet.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded'); + }, this); + + leaflet.DomEvent.addListener(this._wrapper, 'click', this._setupClick, this); + + // make sure both click and touch spawn an address/poi search + leaflet.DomEvent.addListener(this._suggestions, 'mousedown', this.geocodeSuggestion, this); + + leaflet.DomEvent.addListener(this._input, 'blur', function (e) { + this.clear(); + }, this); + + leaflet.DomEvent.addListener(this._input, 'keydown', function (e) { + var text = (e.target || e.srcElement).value; + + leaflet.DomUtil.addClass(this._wrapper, 'geocoder-control-expanded'); + + var list = this._suggestions.querySelectorAll('.' + 'geocoder-control-suggestion'); + var selected = this._suggestions.querySelectorAll('.' + 'geocoder-control-selected')[0]; + var selectedPosition; + + for (var i = 0; i < list.length; i++) { + if (list[i] === selected) { + selectedPosition = i; + break; + } + } + + switch (e.keyCode) { + case 13: + /* + if an item has been selected, geocode it + 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. + if less than two characters have been typed, abort the geocode + */ + if (selected) { + this._input.value = selected.innerText; + this._geosearchCore._geocode(selected.unformattedText, selected['data-magic-key'], selected.provider); + this.clear(); + } else if (this.options.allowMultipleResults && text.length >= 2) { + this._geosearchCore._geocode(this._input.value, undefined); + this.clear(); + } else { + if (list.length === 1) { + leaflet.DomUtil.addClass(list[0], 'geocoder-control-selected'); + this._geosearchCore._geocode(list[0].innerHTML, list[0]['data-magic-key'], list[0].provider); + } else { + this.clear(); + this._input.blur(); + } + } + leaflet.DomEvent.preventDefault(e); + break; + case 38: + if (selected) { + leaflet.DomUtil.removeClass(selected, 'geocoder-control-selected'); + } + + var previousItem = list[selectedPosition - 1]; + + if (selected && previousItem) { + leaflet.DomUtil.addClass(previousItem, 'geocoder-control-selected'); + } else { + leaflet.DomUtil.addClass(list[list.length - 1], 'geocoder-control-selected'); + } + leaflet.DomEvent.preventDefault(e); + break; + case 40: + if (selected) { + leaflet.DomUtil.removeClass(selected, 'geocoder-control-selected'); + } + + var nextItem = list[selectedPosition + 1]; + + if (selected && nextItem) { + leaflet.DomUtil.addClass(nextItem, 'geocoder-control-selected'); + } else { + leaflet.DomUtil.addClass(list[0], 'geocoder-control-selected'); + } + leaflet.DomEvent.preventDefault(e); + break; + default: + // when the input changes we should cancel all pending suggestion requests if possible to avoid result collisions + for (var x = 0; x < this._geosearchCore._pendingSuggestions.length; x++) { + var request = this._geosearchCore._pendingSuggestions[x]; + if (request && request.abort && !request.id) { + request.abort(); + } + } + break; + } + }, this); + + leaflet.DomEvent.addListener(this._input, 'keyup', leaflet.Util.throttle(function (e) { + var key = e.which || e.keyCode; + var text = (e.target || e.srcElement).value; + + // require at least 2 characters for suggestions + if (text.length < 2) { + this._suggestions.innerHTML = ''; + this._suggestions.style.display = 'none'; + leaflet.DomUtil.removeClass(this._input, 'geocoder-control-loading'); + return; + } + + // if this is the escape key it will clear the input so clear suggestions + if (key === 27) { + this._suggestions.innerHTML = ''; + this._suggestions.style.display = 'none'; + return; + } + + // if this is NOT the up/down arrows or enter make a suggestion + if (key !== 13 && key !== 38 && key !== 40) { + if (this._input.value !== this._lastValue) { + this._lastValue = this._input.value; + leaflet.DomUtil.addClass(this._input, 'geocoder-control-loading'); + this._geosearchCore._suggest(text); + } + } + }, 50, this), this); + + leaflet.DomEvent.disableClickPropagation(this._wrapper); + + // when mouse moves over suggestions disable scroll wheel zoom if its enabled + leaflet.DomEvent.addListener(this._suggestions, 'mouseover', function (e) { + if (map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) { + map.scrollWheelZoom.disable(); + } + }); + + // when mouse moves leaves suggestions enable scroll wheel zoom if its disabled + leaflet.DomEvent.addListener(this._suggestions, 'mouseout', function (e) { + if (!map.scrollWheelZoom.enabled() && map.options.scrollWheelZoom) { + map.scrollWheelZoom.enable(); + } + }); + + this._geosearchCore.on('load', function (e) { + leaflet.DomUtil.removeClass(this._input, 'geocoder-control-loading'); + this.clear(); + this._input.blur(); + }, this); + + return this._wrapper; + } +}); + +function geosearch (options) { + return new Geosearch(options); +} + +var FeatureLayerProvider = esriLeaflet.FeatureLayerService.extend({ + options: { + label: 'Feature Layer', + maxResults: 5, + bufferRadius: 1000, + formatSuggestion: function (feature) { + return feature.properties[this.options.searchFields[0]]; + } + }, + + initialize: function (options) { + esriLeaflet.FeatureLayerService.prototype.initialize.call(this, options); + if (typeof this.options.searchFields === 'string') { + this.options.searchFields = [this.options.searchFields]; + } + this._suggestionsQuery = this.query(); + this._resultsQuery = this.query(); + }, + + suggestions: function (text, bounds, callback) { + var query = this._suggestionsQuery.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 = []; + for (var i = results.features.length - 1; i >= 0; i--) { + var feature = results.features[i]; + suggestions.push({ + text: this.options.formatSuggestion.call(this, feature), + unformattedText: feature.properties[this.options.searchFields[0]], + magicKey: feature.id + }); + } + callback(error, suggestions.slice(0, this.options.maxResults)); + } + }, this); + + return request; + }, + + results: function (text, key, bounds, callback) { + var query = this._resultsQuery; + + if (key) { + delete query.params.where; + query.featureIds([key]); + } else { + query.where(this._buildQuery(text)); + } + + if (bounds) { + query.within(bounds); + } + + return query.run(leaflet.Util.bind(function (error, features) { + var results = []; + for (var i = 0; i < features.features.length; i++) { + var feature = features.features[i]; + if (feature) { + var bounds = this._featureBounds(feature); + + var result = { + latlng: bounds.getCenter(), + bounds: bounds, + text: this.options.formatSuggestion.call(this, feature), + properties: feature.properties, + geojson: feature + }; + + results.push(result); + + // clear query parameters for the next search + delete this._resultsQuery.params['objectIds']; + } + } + callback(error, results); + }, this)); + }, + + orderBy: function (fieldName, order) { + this._suggestionsQuery.orderBy(fieldName, order); + }, + + _buildQuery: function (text) { + var queryString = []; + + for (var i = this.options.searchFields.length - 1; i >= 0; i--) { + var field = 'upper("' + this.options.searchFields[i] + '")'; + + queryString.push(field + " LIKE upper('%" + text + "%')"); + } + + if (this.options.where) { + return this.options.where + ' AND (' + queryString.join(' OR ') + ')'; + } else { + return queryString.join(' OR '); + } + }, + + _featureBounds: function (feature) { + var geojson = leaflet.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 leaflet.latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]); + } else { + return geojson.getBounds(); + } + } +}); + +function featureLayerProvider (options) { + return new FeatureLayerProvider(options); +} + +var MapServiceProvider = esriLeaflet.MapService.extend({ + options: { + layers: [0], + label: 'Map Service', + bufferRadius: 1000, + maxResults: 5, + formatSuggestion: function (feature) { + return feature.properties[feature.displayFieldName] + ' ' + feature.layerName + ''; + } + }, + + initialize: function (options) { + esriLeaflet.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 < count; i++) { + var feature = results.features[i]; + var result = raw.results[i]; + var layer = result.layerId; + var idField = this._idFields[layer]; + feature.layerId = layer; + feature.layerName = this._layerNames[layer]; + feature.displayFieldName = this._displayFields[layer]; + if (idField) { + suggestions.push({ + text: this.options.formatSuggestion.call(this, feature), + unformattedText: feature.properties[feature.displayFieldName], + magicKey: result.attributes[idField] + ':' + layer + }); + } + } + } + callback(error, suggestions.reverse()); + }, this); + }, + + results: function (text, key, bounds, callback) { + var results = []; + var request; + + if (key) { + var featureId = key.split(':')[0]; + var layer = key.split(':')[1]; + request = this.query().layer(layer).featureIds(featureId); + } else { + request = this.find().text(text).fields(this.options.searchFields).layers(this.options.layers); + } + + return request.run(function (error, features, response) { + if (!error) { + if (response.results) { + response.results = response.results.reverse(); + } + for (var i = 0; i < features.features.length; i++) { + var feature = features.features[i]; + layer = layer || response.results[i].layerId; + + if (feature && layer !== undefined) { + var bounds = this._featureBounds(feature); + feature.layerId = layer; + feature.layerName = this._layerNames[layer]; + feature.displayFieldName = this._displayFields[layer]; + + var result = { + latlng: bounds.getCenter(), + bounds: bounds, + text: this.options.formatSuggestion.call(this, feature), + properties: feature.properties, + geojson: feature + }; + + results.push(result); + } + } + } + callback(error, results.reverse()); + }, this); + }, + + _featureBounds: function (feature) { + var geojson = leaflet.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 leaflet.latLngBounds([center.lat - latRadius, center.lng - lngRadius], [center.lat + latRadius, center.lng + lngRadius]); + } else { + return geojson.getBounds(); + } + }, + + _layerMetadataCallback: function (layerid) { + return leaflet.Util.bind(function (error, metadata) { + if (error) { return; } + this._displayFields[layerid] = metadata.displayField; + this._layerNames[layerid] = metadata.name; + for (var i = 0; i < metadata.fields.length; i++) { + var field = metadata.fields[i]; + if (field.type === 'esriFieldTypeOID') { + this._idFields[layerid] = field.name; + break; + } + } + }, this); + }, + + _getIdFields: function () { + this._idFields = {}; + this._displayFields = {}; + this._layerNames = {}; + for (var i = 0; i < this.options.layers.length; i++) { + var layer = this.options.layers[i]; + this.get(layer, {}, this._layerMetadataCallback(layer)); + } + } +}); + +function mapServiceProvider (options) { + return new MapServiceProvider(options); +} + +var GeocodeServiceProvider = GeocodeService.extend({ + options: { + label: 'Geocode Server', + maxResults: 5 + }, + + suggestions: function (text, bounds, callback) { + 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, + unformattedText: suggestion.text, + magicKey: suggestion.magicKey + }); + } + } + } + callback(error, suggestions); + }, this); + } else { + callback(undefined, []); + return false; + } + }, + + results: function (text, key, bounds, callback) { + var request = this.geocode().text(text); + + if (key) { + request.key(key); + } + + request.maxLocations(this.options.maxResults); + + if (bounds) { + request.within(bounds); + } + + return request.run(function (error, response) { + callback(error, response.results); + }, this); + } +}); + +function geocodeServiceProvider (options) { + return new GeocodeServiceProvider(options); +} + +exports.VERSION = version; +exports.Geocode = Geocode; +exports.geocode = geocode; +exports.ReverseGeocode = ReverseGeocode; +exports.reverseGeocode = reverseGeocode; +exports.Suggest = Suggest; +exports.suggest = suggest; +exports.GeocodeService = GeocodeService; +exports.geocodeService = geocodeService; +exports.Geosearch = Geosearch; +exports.geosearch = geosearch; +exports.GeosearchCore = GeosearchCore; +exports.geosearchCore = geosearchCore; +exports.ArcgisOnlineProvider = ArcgisOnlineProvider; +exports.arcgisOnlineProvider = arcgisOnlineProvider; +exports.FeatureLayerProvider = FeatureLayerProvider; +exports.featureLayerProvider = featureLayerProvider; +exports.MapServiceProvider = MapServiceProvider; +exports.mapServiceProvider = mapServiceProvider; +exports.GeocodeServiceProvider = GeocodeServiceProvider; +exports.geocodeServiceProvider = geocodeServiceProvider; +exports.WorldGeocodingServiceUrl = WorldGeocodingServiceUrl; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=esri-leaflet-geocoder-debug.js.map diff --git a/dist/esri-leaflet-geocoder-debug.js.map b/dist/esri-leaflet-geocoder-debug.js.map new file mode 100644 index 0000000..7e0eb75 --- /dev/null +++ b/dist/esri-leaflet-geocoder-debug.js.map @@ -0,0 +1 @@ +{"version":3,"file":"esri-leaflet-geocoder-debug.js","sources":["../src/helper.js","../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"],"sourcesContent":["export var WorldGeocodingServiceUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/';\n","import {\n latLng,\n latLngBounds\n} from 'leaflet';\nimport { Task, Util as EsriUtil } from 'esri-leaflet';\nimport { WorldGeocodingServiceUrl } from '../helper';\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 // World Geocoding Service (only works with singleLine)\n 'countries': 'sourceCountry'\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 '../helper';\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 '../helper';\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 '../helper';\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 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, 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\n if (this.options.collapseAfterResult) {\n this._input.value = '';\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\n if (map.attributionControl) {\n map.attributionControl.addAttribution(credits);\n }\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\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._input.value = selected.innerText;\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] + ' ' + 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 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"],"names":["Task","latLngBounds","EsriUtil","latLng","Service","Ev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,IAAI,CAAC;gBACf,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,eAAe,EAAE,UAAU,CAAC,IAAI;gBAChC,QAAQ,EAAE,UAAU,CAAC,QAAQ;eAC9B,CAAC,CAAC;aACJ;WACF;SACF;QACD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;OAC9B,EAAE,IAAI,CAAC,CAAC;KACV,MAAM;MACL,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;MACxB,OAAO,KAAK,CAAC;KACd;GACF;;EAED,OAAO,EAAE,UAAU,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC9C,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;IAExC,IAAI,GAAG,EAAE;MACP,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAClB;;IAED,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;;IAE9C,IAAI,MAAM,EAAE;MACV,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACxB;;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,EAAE,QAAQ,EAAE;MAC5C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;KACnC,EAAE,IAAI,CAAC,CAAC;GACV;CACF,CAAC,CAAC;;AAEH,AAAO,SAAS,sBAAsB,EAAE,OAAO,EAAE;EAC/C,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;CAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/esri-leaflet-geocoder.css b/dist/esri-leaflet-geocoder.css new file mode 100644 index 0000000..eb2b1d7 --- /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-input-disabled{background-color:#f4f4f4;background-image:url("img/search-disabled.png")}.geocoder-control{width:26px;height:26px;-webkit-transition:width .175s ease-in;-moz-transition:width .175s ease-in;-ms-transition:width .175s ease-in;-o-transition:width .175s ease-in;transition:width .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-disabled{background-image:url("img/search@2x-disabled.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:34px}.leaflet-touch .geocoder-control.geocoder-control-expanded{width:275px}.leaflet-touch .geocoder-control-input{height:34px;line-height:30px;background-size:30px}.leaflet-touch .geocoder-control-suggestions{top:30px;width:271px}.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..959174d --- /dev/null +++ b/dist/esri-leaflet-geocoder.js @@ -0,0 +1,5 @@ +/* esri-leaflet-geocoder - v2.2.14 - Mon Mar 11 2019 11:22:03 GMT-0700 (Pacific Daylight Time) + * Copyright (c) 2019 Environmental Systems Research Institute, Inc. + * Apache-2.0 */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("leaflet"),require("esri-leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet","esri-leaflet"],t):t((e.L=e.L||{},e.L.esri=e.L.esri||{},e.L.esri.Geocoding={}),e.L,e.L.esri)}(this,function(e,t,s){"use strict";function i(e){return new p(e)}function o(e){return new f(e)}function r(e){return new v(e)}function n(e){return new m(e)}function a(e,t){return new _(e,t)}function l(e){return new y(e)}function u(e){return new x(e)}function d(e){return new b(e)}function h(e){return new C(e)}function c(e){return new S(e)}var g="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/",p=s.Task.extend({path:"findAddressCandidates",params:{outSr:4326,forStorage:!1,outFields:"*",maxLocations:20},setters:{address:"address",neighborhood:"neighborhood",city:"city",subregion:"subregion",region:"region",postal:"postal",country:"country",text:"singleLine",category:"category",token:"token",key:"magicKey",fields:"outFields",forStorage:"forStorage",maxLocations:"maxLocations",countries:"sourceCountry"},initialize:function(e){e=e||{},e.url=e.url||g,s.Task.prototype.initialize.call(this,e)},within:function(e){return e=t.latLngBounds(e),this.params.searchExtent=s.Util.boundsToExtent(e),this},nearby:function(e,s){var i=t.latLng(e);return this.params.location=i.lng+","+i.lat,this.params.distance=Math.min(Math.max(s,2e3),5e4),this},run:function(e,t){return this.options.customParam&&(this.params[this.options.customParam]=this.params.singleLine,delete this.params.singleLine),this.request(function(s,i){var o=this._processGeocoderResponse,r=s?void 0:o(i);e.call(t,s,{results:r},i)},this)},_processGeocoderResponse:function(e){for(var i=[],o=0;o-1?this.options.supportsSuggest=!0:this.options.supportsSuggest=!1,this.options.customParam=t.singleLineAddressField.name)},this)}}),_=t.Evented.extend({options:{zoomToResult:!0,useMapBounds:12,searchBounds:null},initialize:function(e,s){if(t.Util.setOptions(this,s),this._control=e,!s||!s.providers||!s.providers.length)throw new Error("You must specify at least one provider");this._providers=s.providers},_geocode:function(e,s,i){var o,r=0,n=[],a=t.Util.bind(function(t,s){r--,t||(s&&(n=n.concat(s)),r<=0&&(o=this._boundsFromResults(n),this.fire("results",{results:n,bounds:o,latlng:o?o.getCenter():void 0,text:e},!0),this.options.zoomToResult&&o&&this._control._map.fitBounds(o),this.fire("load")))},this);if(s)r++,i.results(e,s,this._searchBounds(),a);else for(var l=0;l=0;r--){var n=e[r];o.push(n.latlng),n.bounds&&n.bounds.isValid()&&!n.bounds.equals(s)&&i.push(n.bounds)}for(var a=t.latLngBounds(o),l=0;l0&&(this._suggestions.style.display="block"),this._suggestions.style.maxHeight=this._map.getSize().y-this._suggestions.offsetTop-this._wrapper.offsetTop-10+"px";for(var i,o,r=[],n=[],a=0;a1&&s!==l.provider.options.label&&(o=t.DomUtil.create("span","geocoder-control-header",this._suggestions),o.textContent=l.provider.options.label,o.innerText=l.provider.options.label,s=l.provider.options.label,r.push(o)),i||(i=t.DomUtil.create("ul","geocoder-control-list",this._suggestions)),-1===n.indexOf(l.text)){var u=t.DomUtil.create("li","geocoder-control-suggestion",i);u.innerHTML=l.text,u.provider=l.provider,u["data-magic-key"]=l.magicKey,u.unformattedText=l.unformattedText}else for(var d=0;d=0;r--){var n=e[r];o.push(n.latlng),n.bounds&&n.bounds.isValid()&&!n.bounds.equals(s)&&i.push(n.bounds)}for(var a=t.latLngBounds(o),l=0;l=2?(this._geosearchCore._geocode(this._input.value,void 0),this.clear()):1===o.length?(t.DomUtil.addClass(o[0],"geocoder-control-selected"),this._geosearchCore._geocode(o[0].innerHTML,o[0]["data-magic-key"],o[0].provider)):(this.clear(),this._input.blur()),t.DomEvent.preventDefault(e);break;case 38:r&&t.DomUtil.removeClass(r,"geocoder-control-selected");var a=o[i-1];r&&a?t.DomUtil.addClass(a,"geocoder-control-selected"):t.DomUtil.addClass(o[o.length-1],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;case 40:r&&t.DomUtil.removeClass(r,"geocoder-control-selected");var l=o[i+1];r&&l?t.DomUtil.addClass(l,"geocoder-control-selected"):t.DomUtil.addClass(o[0],"geocoder-control-selected"),t.DomEvent.preventDefault(e);break;default:for(var u=0;u=0;r--){var n=t.features[r];o.push({text:this.options.formatSuggestion.call(this,n),unformattedText:n.properties[this.options.searchFields[0]],magicKey:n.id})}s(e,o.slice(0,this.options.maxResults))}},this)},results:function(e,s,i,o){var r=this._resultsQuery;return s?(delete r.params.where,r.featureIds([s])):r.where(this._buildQuery(e)),i&&r.within(i),r.run(t.Util.bind(function(e,t){for(var s=[],i=0;i=0;s--){var i='upper("'+this.options.searchFields[s]+'")';t.push(i+" LIKE upper('%"+e+"%')")}return this.options.where?this.options.where+" AND ("+t.join(" OR ")+")":t.join(" OR ")},_featureBounds:function(e){var s=t.geoJson(e);if("Point"===e.geometry.type){var i=s.getBounds().getCenter(),o=this.options.bufferRadius/40075017*360/Math.cos(180/Math.PI*i.lat),r=this.options.bufferRadius/40075017*360;return t.latLngBounds([i.lat-r,i.lng-o],[i.lat+r,i.lng+o])}return s.getBounds()}}),C=s.MapService.extend({options:{layers:[0],label:"Map Service",bufferRadius:1e3,maxResults:5,formatSuggestion:function(e){return e.properties[e.displayFieldName]+" "+e.layerName+""}},initialize:function(e){s.MapService.prototype.initialize.call(this,e),this._getIdFields()},suggestions:function(e,t,s){return this.find().text(e).fields(this.options.searchFields).returnGeometry(!1).layers(this.options.layers).run(function(e,t,i){var o=[];if(!e){var r=Math.min(this.options.maxResults,t.features.length);i.results=i.results.reverse();for(var n=0;n -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 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, 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\n if (this.options.collapseAfterResult) {\n this._input.value = '';\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\n if (map.attributionControl) {\n map.attributionControl.addAttribution(credits);\n }\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\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._input.value = selected.innerText;\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] + ' ' + 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 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 var WorldGeocodingServiceUrl = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/';\n"],"names":["geocode","options","Geocode","reverseGeocode","ReverseGeocode","suggest","Suggest","geocodeService","GeocodeService","geosearchCore","control","GeosearchCore","arcgisOnlineProvider","ArcgisOnlineProvider","geosearch","Geosearch","featureLayerProvider","FeatureLayerProvider","mapServiceProvider","MapServiceProvider","geocodeServiceProvider","GeocodeServiceProvider","WorldGeocodingServiceUrl","Task","extend","path","params","outSr","forStorage","outFields","maxLocations","setters","address","neighborhood","city","subregion","region","postal","country","text","category","token","key","fields","countries","initialize","url","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","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":";;;2TAyFA,SAAgBA,GAASC,GACvB,MAAO,IAAIC,GAAQD,GC1CrB,QAAgBE,GAAgBF,GAC9B,MAAO,IAAIG,GAAeH,GCS5B,QAAgBI,GAASJ,GACvB,MAAO,IAAIK,GAAQL,GCTrB,Q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O,aACLxO,KAAK0O,kBACL1O,KAAKyO,cACL,KAAK,GAAI1M,GAAI,EAAGA,EAAI/B,KAAKhD,QAAQgR,OAAO/L,OAAQF,IAAK,CACnD,GAAIuM,GAAQtO,KAAKhD,QAAQgR,OAAOjM,EAChC/B,MAAKgP,IAAIV,KAAWtO,KAAK6O,uBAAuBP,QC1H3ClQ,EAAyBb,EAAegB,QACjDvB,SACEqK,MAAO,iBACPC,WAAY,GAGd5B,YAAa,SAAUpG,EAAMY,EAAQkB,GACnC,GAAIpB,KAAKhD,QAAQkG,gBAAiB,CAChC,GAAI1B,GAAUxB,KAAK5C,UAAUkC,KAAKA,EAKlC,OAJIY,IACFsB,EAAQvB,OAAOC,GAGVsB,EAAQL,IAAI,SAAUM,EAAOI,EAASH,GAC3C,GAAIgE,KACJ,KAAKjE,EACH,KAAOC,EAASgE,YAAYzD,QAAUyD,EAAYzD,QAAWjC,KAAKhD,QAAQsK,WAAa,GAAI,CACzF,GAAIE,GAAa9F,EAASgE,YAAY+B,OACjCD,GAAWE,cACdhC,EAAYrD,MACV/C,KAAMkI,EAAWlI,KACjBqI,gBAAiBH,EAAWlI,KAC5BsI,SAAUJ,EAAWI,WAK7BxG,EAASK,EAAOiE,IACf1F,MAGH,MADAoB,OAASU,QACF,GAIXD,QAAS,SAAUvC,EAAMG,EAAKS,EAAQkB,GACpC,GAAII,GAAUxB,KAAKjD,UAAUuC,KAAKA,EAYlC,OAVIG,IACF+B,EAAQ/B,IAAIA,GAGd+B,EAAQ3C,aAAamB,KAAKhD,QAAQsK,YAE9BpH,GACFsB,EAAQvB,OAAOC,GAGVsB,EAAQL,IAAI,SAAUM,EAAOC,GAClCN,EAASK,EAAOC,EAASG,UACxB7B"} \ No newline at end of file diff --git a/dist/img/loading.gif b/dist/img/loading.gif new file mode 100644 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 100644 index 0000000..ceec3a1 Binary files /dev/null and b/dist/img/loading@2x.gif differ diff --git a/dist/img/search-disabled.png b/dist/img/search-disabled.png new file mode 100644 index 0000000..7f8f5bb Binary files /dev/null and b/dist/img/search-disabled.png 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-disabled.png b/dist/img/search@2x-disabled.png new file mode 100644 index 0000000..5ae89b3 Binary files /dev/null and b/dist/img/search@2x-disabled.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