diff --git a/assets/control-geocoder/Control.Geocoder.js b/assets/control-geocoder/Control.Geocoder.js index e7d5b28..53af88b 100644 --- a/assets/control-geocoder/Control.Geocoder.js +++ b/assets/control-geocoder/Control.Geocoder.js @@ -1,7 +1,7 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0){this._alts.innerHTML="",this._results=e,n.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized");for(var o=0;o=0?this._collapse():this._expand()},_expand:function(){n.DomUtil.addClass(this._container,"leaflet-control-geocoder-expanded"),this._input.select(),this.fire("expand")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-geocoder-expanded",""),n.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),n.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),this.fire("collapse")},_clearResults:function(){n.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),this._selection=null,n.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error")},_createAlt:function(e,t){var o=n.DomUtil.create("li",""),s=n.DomUtil.create("a","",o),i=this.options.showResultIcons&&e.icon?n.DomUtil.create("img","",s):null,r=e.html?void 0:document.createTextNode(e.name),a=function(t){n.DomEvent.preventDefault(t),this._geocodeResultSelected(e)};return i&&(i.src=e.icon),o.setAttribute("data-result-index",t),e.html?s.innerHTML=s.innerHTML+e.html:s.appendChild(r),n.DomEvent.addListener(o,"mousedown",a,this),o},_keydown:function(e){var t=this,o=function(e){t._selection&&(n.DomUtil.removeClass(t._selection,"leaflet-control-geocoder-selected"),t._selection=t._selection[e>0?"nextSibling":"previousSibling"]),t._selection||(t._selection=t._alts[e>0?"firstChild":"lastChild"]),t._selection&&n.DomUtil.addClass(t._selection,"leaflet-control-geocoder-selected")};switch(e.keyCode){case 27:this.options.collapsed&&this._collapse();break;case 38:o(-1),n.DomEvent.preventDefault(e);break;case 40:o(1),n.DomEvent.preventDefault(e);break;case 13:if(this._selection){var s=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[s]),this._clearResults()}else this._geocode();n.DomEvent.preventDefault(e);break;default:var i=this._input.value;this.options.geocoder.suggest&&i!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),i.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(n.bind(function(){this._geocode(!0)},this),this.options.suggestTimeout):this._clearResults())}}}),factory:function(e){return new n.Control.Geocoder(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./geocoders/nominatim":9}],2:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{service_url:"http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"},initialize:function(e,t){n.setOptions(this,t),this._accessToken=e},geocode:function(e,t,o){var i={SingleLine:e,outFields:"Addr_Type",forStorage:!1,maxLocations:10,f:"json"};this._key&&this._key.length&&(i.token=this._key),s.getJSON(this.options.service_url+"/findAddressCandidates",i,function(e){var s,i,r,a=[];if(e.candidates&&e.candidates.length)for(var l=0;l<=e.candidates.length-1;l++)s=e.candidates[l],i=n.latLng(s.location.y,s.location.x),r=n.latLngBounds(n.latLng(s.extent.ymax,s.extent.xmax),n.latLng(s.extent.ymin,s.extent.xmin)),a[l]={name:s.address,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r={location:encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat),distance:100,f:"json"};s.getJSON(this.options.service_url+"/reverseGeocode",r,function(e){var t,s=[];e&&!e.error&&(t=n.latLng(e.location.y,e.location.x),s.push({name:e.address.Match_addr,center:t,bounds:n.latLngBounds(t,t)})),o.call(i,s)})}}),factory:function(e,t){return new n.Control.Geocoder.ArcGis(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],3:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({initialize:function(e){this.key=e},geocode:function(e,t,o){s.jsonp("https://dev.virtualearth.net/REST/v1/Locations",{query:e,key:this.key},function(e){var s=[];if(e.resourceSets.length>0)for(var i=e.resourceSets[0].resources.length-1;i>=0;i--){var r=e.resourceSets[0].resources[i],a=r.bbox;s[i]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}t.call(o,s)},this,"jsonp")},reverse:function(e,t,o,i){s.jsonp("//dev.virtualearth.net/REST/v1/Locations/"+e.lat+","+e.lng,{key:this.key},function(e){for(var t=[],s=e.resourceSets[0].resources.length-1;s>=0;s--){var r=e.resourceSets[0].resources[s],a=r.bbox;t[s]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}o.call(i,t)},this,"jsonp")}}),factory:function(e){return new n.Control.Geocoder.Bing(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],4:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){this._key=e,n.setOptions(this,t),this.options.serviceUrl=this.options.service_url||this.options.serviceUrl},geocode:function(e,t,o){var i={address:e};this._key&&this._key.length&&(i.key=this._key),i=n.Util.extend(i,this.options.geocodingQueryParams),s.getJSON(this.options.serviceUrl,i,function(e){var s,i,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)s=e.results[l],i=n.latLng(s.geometry.location),r=n.latLngBounds(n.latLng(s.geometry.viewport.northeast),n.latLng(s.geometry.viewport.southwest)),a[l]={name:s.formatted_address,bbox:r,center:i,properties:s.address_components};t.call(o,a)})},reverse:function(e,t,o,i){var r={latlng:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng)};r=n.Util.extend(r,this.options.reverseQueryParams),this._key&&this._key.length&&(r.key=this._key),s.getJSON(this.options.serviceUrl,r,function(e){var t,s,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)t=e.results[l],s=n.latLng(t.geometry.location),r=n.latLngBounds(n.latLng(t.geometry.viewport.northeast),n.latLng(t.geometry.viewport.southwest)),a[l]={name:t.formatted_address,bbox:r,center:s,properties:t.address_components};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Google(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],5:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{geocodeUrl:"http://geocoder.api.here.com/6.2/geocode.json",reverseGeocodeUrl:"http://reverse.geocoder.api.here.com/6.2/reversegeocode.json",app_id:"",app_code:"",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var s={searchtext:e,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1};s=n.Util.extend(s,this.options.geocodingQueryParams),this.getJSON(this.options.geocodeUrl,s,t,o)},reverse:function(e,t,o,s){var i={prox:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng),mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1};i=n.Util.extend(i,this.options.reverseQueryParams),this.getJSON(this.options.reverseGeocodeUrl,i,o,s)},getJSON:function(e,t,o,i){s.getJSON(e,t,function(e){var t,s,r,a=[];if(e.response.view&&e.response.view.length)for(var l=0;l<=e.response.view[0].result.length-1;l++)t=e.response.view[0].result[l].location,s=n.latLng(t.displayPosition.latitude,t.displayPosition.longitude),r=n.latLngBounds(n.latLng(t.mapView.topLeft.latitude,t.mapView.topLeft.longitude),n.latLng(t.mapView.bottomRight.latitude,t.mapView.bottomRight.longitude)),a[l]={name:t.address.label,bbox:r,center:s};o.call(i,a)})}}),factory:function(e){return new n.Control.Geocoder.HERE(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],6:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/"},initialize:function(e,t){n.setOptions(this,t),this._accessToken=e},geocode:function(e,t,o){s.getJSON(this.options.serviceUrl+encodeURIComponent(e)+".json",{access_token:this._accessToken},function(e){var s,i,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)s=e.features[l],i=n.latLng(s.center.reverse()),r=s.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(s.bbox.slice(0,2).reverse()),n.latLng(s.bbox.slice(2,4).reverse())):n.latLngBounds(i,i),a[l]={name:s.place_name,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){s.getJSON(this.options.serviceUrl+encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat)+".json",{access_token:this._accessToken},function(e){var t,s,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)t=e.features[l],s=n.latLng(t.center.reverse()),r=t.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(t.bbox.slice(0,2).reverse()),n.latLng(t.bbox.slice(2,4).reverse())):n.latLngBounds(s,s),a[l]={name:t.place_name,bbox:r,center:s};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Mapbox(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],7:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"},initialize:function(e,t){this._key=decodeURIComponent(e),n.Util.setOptions(this,t)},_formatName:function(){var e,t=[];for(e=0;e=0;a--)s=e.results[0].locations[a],i=n.latLng(s.latLng),r[a]={name:this._formatName(s.street,s.adminArea4,s.adminArea3,s.adminArea1),bbox:n.latLngBounds(i,i),center:i};t.call(o,r)},this)},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"/reverse",{key:this._key,location:e.lat+","+e.lng,outputFormat:"json"},function(e){var t,s,r=[];if(e.results&&e.results[0].locations)for(var a=e.results[0].locations.length-1;a>=0;a--)t=e.results[0].locations[a],s=n.latLng(t.latLng),r[a]={name:this._formatName(t.street,t.adminArea4,t.adminArea3,t.adminArea1),bbox:n.latLngBounds(s,s),center:s};o.call(i,r)},this)}}),factory:function(e,t){return new n.Control.Geocoder.MapQuest(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],8:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://search.mapzen.com/v1",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){n.Util.setOptions(this,t),this._apiKey=e,this._lastSuggest=0},geocode:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/search",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),function(e){t.call(o,i._parseResults(e,"bbox"))})},suggest:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/autocomplete",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),n.bind(function(e){e.geocoding.timestamp>this._lastSuggest&&(this._lastSuggest=e.geocoding.timestamp,t.call(o,i._parseResults(e,"bbox")))},this))},reverse:function(e,t,o,i){var r=this;s.getJSON(this.options.serviceUrl+"/reverse",n.extend({api_key:this._apiKey,"point.lat":e.lat,"point.lon":e.lng},this.options.reverseQueryParams),function(e){o.call(i,r._parseResults(e,"bounds"))})},_parseResults:function(e,t){var o=[];return n.geoJson(e,{pointToLayer:function(e,t){return n.circleMarker(t)},onEachFeature:function(e,s){var i,r,a={};s.getBounds?(i=s.getBounds(),r=i.getCenter()):(r=s.getLatLng(),i=n.latLngBounds(r,r)),a.name=s.feature.properties.label,a.center=r,a[t]=i,a.properties=s.feature.properties,o.push(a)}}),o}}),factory:function(e,t){return new n.Control.Geocoder.Mapzen(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],9:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://nominatim.openstreetmap.org/",geocodingQueryParams:{},reverseQueryParams:{},htmlTemplate:function(e){var t=e.address,o=[];return(t.road||t.building)&&o.push("{building} {road} {house_number}"),(t.city||t.town||t.village||t.hamlet)&&o.push('{postcode} {city} {town} {village} {hamlet}'),(t.state||t.country)&&o.push('{state} {country}'),s.template(o.join("
"),t,!0)}},initialize:function(e){n.Util.setOptions(this,e)},geocode:function(e,t,o){s.jsonp(this.options.serviceUrl+"search",n.extend({q:e,limit:5,format:"json",addressdetails:1},this.options.geocodingQueryParams),function(e){for(var s=[],i=e.length-1;i>=0;i--){for(var r=e[i].boundingbox,a=0;a<4;a++)r[a]=parseFloat(r[a]);s[i]={icon:e[i].icon,name:e[i].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e[i]):void 0,bbox:n.latLngBounds([r[0],r[2]],[r[1],r[3]]),center:n.latLng(e[i].lat,e[i].lon),properties:e[i]}}t.call(o,s)},this,"json_callback")},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"reverse",n.extend({lat:e.lat,lon:e.lng,zoom:Math.round(Math.log(t/256)/Math.log(2)),addressdetails:1,format:"json"},this.options.reverseQueryParams),function(e){var t,s=[];e&&e.lat&&e.lon&&(t=n.latLng(e.lat,e.lon),s.push({name:e.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e):void 0,center:t,bounds:n.latLngBounds(t,t),properties:e})),o.call(i,s)},this,"json_callback")}}),factory:function(e){return new n.Control.Geocoder.Nominatim(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],10:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://photon.komoot.de/api/",reverseUrl:"https://photon.komoot.de/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var i=n.extend({q:e},this.options.geocodingQueryParams);s.getJSON(this.options.serviceUrl,i,n.bind(function(e){t.call(o,this._decodeFeatures(e))},this))},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r=n.extend({lat:e.lat,lon:e.lng},this.options.geocodingQueryParams);s.getJSON(this.options.reverseUrl,r,n.bind(function(e){o.call(i,this._decodeFeatures(e))},this))},_decodeFeatures:function(e){var t,o,s,i,r,a,l=[];if(e&&e.features)for(t=0;t"'`]/g,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return function(n){return null==n?"":n?(n=""+n,o.test(n)?n.replace(t,e):n):n+""}}();t.exports={jsonp:function(e,t,s,i,r){var a="_l_geocoder_"+n++;t[r||"callback"]=a,window[a]=o.Util.bind(s,i);var l=document.createElement("script");l.type="text/javascript",l.src=e+o.Util.getParamString(t),l.id=a,document.getElementsByTagName("head")[0].appendChild(l)},getJSON:function(e,t,n){var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)return 200!==s.status&&304!==s.status?void n(""):void n(JSON.parse(s.response))},s.open("GET",e+o.Util.getParamString(t),!0),s.setRequestHeader("Accept","application/json"),s.send(null)},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,o){var n=t[o];return void 0===n?n="":"function"==typeof n&&(n=n(t)),s(n)})},htmlEscape:s}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[12]); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.leafletControlGeocoder=e()}}(function(){return function e(t,o,n){function s(r,a){if(!o[r]){if(!t[r]){var l="function"==typeof require&&require;if(!a&&l)return l(r,!0);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var d=o[r]={exports:{}};t[r][0].call(d.exports,function(e){var o=t[r][1][e];return s(o?o:e)},d,d.exports,e,t,o,n)}return o[r].exports}for(var i="function"==typeof require&&require,r=0;r0){this._alts.innerHTML="",this._results=e,n.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized");for(var o=0;o=0?this._collapse():this._expand()},_expand:function(){n.DomUtil.addClass(this._container,"leaflet-control-geocoder-expanded"),this._input.select(),this.fire("expand")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-geocoder-expanded",""),n.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),n.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error"),this.fire("collapse")},_clearResults:function(){n.DomUtil.addClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),this._selection=null,n.DomUtil.removeClass(this._errorElement,"leaflet-control-geocoder-error")},_createAlt:function(e,t){var o=n.DomUtil.create("li",""),s=n.DomUtil.create("a","",o),i=this.options.showResultIcons&&e.icon?n.DomUtil.create("img","",s):null,r=e.html?void 0:document.createTextNode(e.name),a=function(t){this._preventBlurCollapse=!0,n.DomEvent.stop(t),this._geocodeResultSelected(e),n.DomEvent.on(o,"click",function(){this.options.collapsed&&this._collapse()},this)};return i&&(i.src=e.icon),o.setAttribute("data-result-index",t),e.html?s.innerHTML=s.innerHTML+e.html:s.appendChild(r),n.DomEvent.addListener(o,"mousedown",a,this),o},_keydown:function(e){var t=this,o=function(e){t._selection&&(n.DomUtil.removeClass(t._selection,"leaflet-control-geocoder-selected"),t._selection=t._selection[e>0?"nextSibling":"previousSibling"]),t._selection||(t._selection=t._alts[e>0?"firstChild":"lastChild"]),t._selection&&n.DomUtil.addClass(t._selection,"leaflet-control-geocoder-selected")};switch(e.keyCode){case 27:this.options.collapsed&&this._collapse();break;case 38:o(-1),n.DomEvent.preventDefault(e);break;case 40:o(1),n.DomEvent.preventDefault(e);break;case 13:if(this._selection){var s=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[s]),this._clearResults()}else this._geocode();n.DomEvent.preventDefault(e);break;default:var i=this._input.value;this.options.geocoder.suggest&&i!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),i.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(n.bind(function(){this._geocode(!0)},this),this.options.suggestTimeout):this._clearResults())}}}),factory:function(e){return new n.Control.Geocoder(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./geocoders/nominatim":9}],2:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{service_url:"http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"},initialize:function(e,t){n.setOptions(this,t),this._accessToken=e},geocode:function(e,t,o){var i={SingleLine:e,outFields:"Addr_Type",forStorage:!1,maxLocations:10,f:"json"};this._key&&this._key.length&&(i.token=this._key),s.getJSON(this.options.service_url+"/findAddressCandidates",i,function(e){var s,i,r,a=[];if(e.candidates&&e.candidates.length)for(var l=0;l<=e.candidates.length-1;l++)s=e.candidates[l],i=n.latLng(s.location.y,s.location.x),r=n.latLngBounds(n.latLng(s.extent.ymax,s.extent.xmax),n.latLng(s.extent.ymin,s.extent.xmin)),a[l]={name:s.address,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r={location:encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat),distance:100,f:"json"};s.getJSON(this.options.service_url+"/reverseGeocode",r,function(e){var t,s=[];e&&!e.error&&(t=n.latLng(e.location.y,e.location.x),s.push({name:e.address.Match_addr,center:t,bounds:n.latLngBounds(t,t)})),o.call(i,s)})}}),factory:function(e,t){return new n.Control.Geocoder.ArcGis(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],3:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({initialize:function(e){this.key=e},geocode:function(e,t,o){s.jsonp("https://dev.virtualearth.net/REST/v1/Locations",{query:e,key:this.key},function(e){var s=[];if(e.resourceSets.length>0)for(var i=e.resourceSets[0].resources.length-1;i>=0;i--){var r=e.resourceSets[0].resources[i],a=r.bbox;s[i]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}t.call(o,s)},this,"jsonp")},reverse:function(e,t,o,i){s.jsonp("//dev.virtualearth.net/REST/v1/Locations/"+e.lat+","+e.lng,{key:this.key},function(e){for(var t=[],s=e.resourceSets[0].resources.length-1;s>=0;s--){var r=e.resourceSets[0].resources[s],a=r.bbox;t[s]={name:r.name,bbox:n.latLngBounds([a[0],a[1]],[a[2],a[3]]),center:n.latLng(r.point.coordinates)}}o.call(i,t)},this,"jsonp")}}),factory:function(e){return new n.Control.Geocoder.Bing(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],4:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){this._key=e,n.setOptions(this,t),this.options.serviceUrl=this.options.service_url||this.options.serviceUrl},geocode:function(e,t,o){var i={address:e};this._key&&this._key.length&&(i.key=this._key),i=n.Util.extend(i,this.options.geocodingQueryParams),s.getJSON(this.options.serviceUrl,i,function(e){var s,i,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)s=e.results[l],i=n.latLng(s.geometry.location),r=n.latLngBounds(n.latLng(s.geometry.viewport.northeast),n.latLng(s.geometry.viewport.southwest)),a[l]={name:s.formatted_address,bbox:r,center:i,properties:s.address_components};t.call(o,a)})},reverse:function(e,t,o,i){var r={latlng:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng)};r=n.Util.extend(r,this.options.reverseQueryParams),this._key&&this._key.length&&(r.key=this._key),s.getJSON(this.options.serviceUrl,r,function(e){var t,s,r,a=[];if(e.results&&e.results.length)for(var l=0;l<=e.results.length-1;l++)t=e.results[l],s=n.latLng(t.geometry.location),r=n.latLngBounds(n.latLng(t.geometry.viewport.northeast),n.latLng(t.geometry.viewport.southwest)),a[l]={name:t.formatted_address,bbox:r,center:s,properties:t.address_components};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Google(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],5:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{geocodeUrl:"http://geocoder.api.here.com/6.2/geocode.json",reverseGeocodeUrl:"http://reverse.geocoder.api.here.com/6.2/reversegeocode.json",app_id:"",app_code:"",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var s={searchtext:e,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1};s=n.Util.extend(s,this.options.geocodingQueryParams),this.getJSON(this.options.geocodeUrl,s,t,o)},reverse:function(e,t,o,s){var i={prox:encodeURIComponent(e.lat)+","+encodeURIComponent(e.lng),mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1};i=n.Util.extend(i,this.options.reverseQueryParams),this.getJSON(this.options.reverseGeocodeUrl,i,o,s)},getJSON:function(e,t,o,i){s.getJSON(e,t,function(e){var t,s,r,a=[];if(e.response.view&&e.response.view.length)for(var l=0;l<=e.response.view[0].result.length-1;l++)t=e.response.view[0].result[l].location,s=n.latLng(t.displayPosition.latitude,t.displayPosition.longitude),r=n.latLngBounds(n.latLng(t.mapView.topLeft.latitude,t.mapView.topLeft.longitude),n.latLng(t.mapView.bottomRight.latitude,t.mapView.bottomRight.longitude)),a[l]={name:t.address.label,bbox:r,center:s};o.call(i,a)})}}),factory:function(e){return new n.Control.Geocoder.HERE(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],6:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/"},initialize:function(e,t){n.setOptions(this,t),this._accessToken=e},geocode:function(e,t,o){s.getJSON(this.options.serviceUrl+encodeURIComponent(e)+".json",{access_token:this._accessToken},function(e){var s,i,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)s=e.features[l],i=n.latLng(s.center.reverse()),r=s.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(s.bbox.slice(0,2).reverse()),n.latLng(s.bbox.slice(2,4).reverse())):n.latLngBounds(i,i),a[l]={name:s.place_name,bbox:r,center:i};t.call(o,a)})},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){s.getJSON(this.options.serviceUrl+encodeURIComponent(e.lng)+","+encodeURIComponent(e.lat)+".json",{access_token:this._accessToken},function(e){var t,s,r,a=[];if(e.features&&e.features.length)for(var l=0;l<=e.features.length-1;l++)t=e.features[l],s=n.latLng(t.center.reverse()),r=t.hasOwnProperty("bbox")?n.latLngBounds(n.latLng(t.bbox.slice(0,2).reverse()),n.latLng(t.bbox.slice(2,4).reverse())):n.latLngBounds(s,s),a[l]={name:t.place_name,bbox:r,center:s};o.call(i,a)})}}),factory:function(e,t){return new n.Control.Geocoder.Mapbox(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],7:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"},initialize:function(e,t){this._key=decodeURIComponent(e),n.Util.setOptions(this,t)},_formatName:function(){var e,t=[];for(e=0;e=0;a--)s=e.results[0].locations[a],i=n.latLng(s.latLng),r[a]={name:this._formatName(s.street,s.adminArea4,s.adminArea3,s.adminArea1),bbox:n.latLngBounds(i,i),center:i};t.call(o,r)},this)},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"/reverse",{key:this._key,location:e.lat+","+e.lng,outputFormat:"json"},function(e){var t,s,r=[];if(e.results&&e.results[0].locations)for(var a=e.results[0].locations.length-1;a>=0;a--)t=e.results[0].locations[a],s=n.latLng(t.latLng),r[a]={name:this._formatName(t.street,t.adminArea4,t.adminArea3,t.adminArea1),bbox:n.latLngBounds(s,s),center:s};o.call(i,r)},this)}}),factory:function(e,t){return new n.Control.Geocoder.MapQuest(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],8:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://search.mapzen.com/v1",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(e,t){n.Util.setOptions(this,t),this._apiKey=e,this._lastSuggest=0},geocode:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/search",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),function(e){t.call(o,i._parseResults(e,"bbox"))})},suggest:function(e,t,o){var i=this;s.getJSON(this.options.serviceUrl+"/autocomplete",n.extend({api_key:this._apiKey,text:e},this.options.geocodingQueryParams),n.bind(function(e){e.geocoding.timestamp>this._lastSuggest&&(this._lastSuggest=e.geocoding.timestamp,t.call(o,i._parseResults(e,"bbox")))},this))},reverse:function(e,t,o,i){var r=this;s.getJSON(this.options.serviceUrl+"/reverse",n.extend({api_key:this._apiKey,"point.lat":e.lat,"point.lon":e.lng},this.options.reverseQueryParams),function(e){o.call(i,r._parseResults(e,"bounds"))})},_parseResults:function(e,t){var o=[];return n.geoJson(e,{pointToLayer:function(e,t){return n.circleMarker(t)},onEachFeature:function(e,s){var i,r,a={};s.getBounds?(i=s.getBounds(),r=i.getCenter()):(r=s.getLatLng(),i=n.latLngBounds(r,r)),a.name=s.feature.properties.label,a.center=r,a[t]=i,a.properties=s.feature.properties,o.push(a)}}),o}}),factory:function(e,t){return new n.Control.Geocoder.Mapzen(e,t)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],9:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://nominatim.openstreetmap.org/",geocodingQueryParams:{},reverseQueryParams:{},htmlTemplate:function(e){var t=e.address,o=[];return(t.road||t.building)&&o.push("{building} {road} {house_number}"),(t.city||t.town||t.village||t.hamlet)&&o.push('{postcode} {city} {town} {village} {hamlet}'),(t.state||t.country)&&o.push('{state} {country}'),s.template(o.join("
"),t,!0)}},initialize:function(e){n.Util.setOptions(this,e)},geocode:function(e,t,o){s.jsonp(this.options.serviceUrl+"search",n.extend({q:e,limit:5,format:"json",addressdetails:1},this.options.geocodingQueryParams),function(e){for(var s=[],i=e.length-1;i>=0;i--){for(var r=e[i].boundingbox,a=0;a<4;a++)r[a]=parseFloat(r[a]);s[i]={icon:e[i].icon,name:e[i].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e[i]):void 0,bbox:n.latLngBounds([r[0],r[2]],[r[1],r[3]]),center:n.latLng(e[i].lat,e[i].lon),properties:e[i]}}t.call(o,s)},this,"json_callback")},reverse:function(e,t,o,i){s.jsonp(this.options.serviceUrl+"reverse",n.extend({lat:e.lat,lon:e.lng,zoom:Math.round(Math.log(t/256)/Math.log(2)),addressdetails:1,format:"json"},this.options.reverseQueryParams),function(e){var t,s=[];e&&e.lat&&e.lon&&(t=n.latLng(e.lat,e.lon),s.push({name:e.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(e):void 0,center:t,bounds:n.latLngBounds(t,t),properties:e})),o.call(i,s)},this,"json_callback")}}),factory:function(e){return new n.Control.Geocoder.Nominatim(e)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../util":13}],10:[function(e,t,o){(function(o){var n="undefined"!=typeof window?window.L:"undefined"!=typeof o?o.L:null,s=e("../util");t.exports={class:n.Class.extend({options:{serviceUrl:"https://photon.komoot.de/api/",reverseUrl:"https://photon.komoot.de/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]},initialize:function(e){n.setOptions(this,e)},geocode:function(e,t,o){var i=n.extend({q:e},this.options.geocodingQueryParams);s.getJSON(this.options.serviceUrl,i,n.bind(function(e){t.call(o,this._decodeFeatures(e))},this))},suggest:function(e,t,o){return this.geocode(e,t,o)},reverse:function(e,t,o,i){var r=n.extend({lat:e.lat,lon:e.lng},this.options.geocodingQueryParams);s.getJSON(this.options.reverseUrl,r,n.bind(function(e){o.call(i,this._decodeFeatures(e))},this))},_decodeFeatures:function(e){var t,o,s,i,r,a,l=[];if(e&&e.features)for(t=0;t"'`]/g,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return function(n){return null==n?"":n?(n=""+n,o.test(n)?n.replace(t,e):n):n+""}}();t.exports={jsonp:function(e,t,s,i,r){var a="_l_geocoder_"+n++;t[r||"callback"]=a,window[a]=o.Util.bind(s,i);var l=document.createElement("script");l.type="text/javascript",l.src=e+o.Util.getParamString(t),l.id=a,document.getElementsByTagName("head")[0].appendChild(l)},getJSON:function(e,t,n){var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)return 200!==s.status&&304!==s.status?void n(""):void n(JSON.parse(s.response))},s.open("GET",e+o.Util.getParamString(t),!0),s.setRequestHeader("Accept","application/json"),s.send(null)},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,o){var n=t[o];return void 0===n?n="":"function"==typeof n&&(n=n(t)),s(n)})},htmlEscape:s}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[12])(12)}); \ No newline at end of file diff --git a/assets/control-geocoder/README.md b/assets/control-geocoder/README.md old mode 100644 new mode 100755 index 70c700b..bf8e556 --- a/assets/control-geocoder/README.md +++ b/assets/control-geocoder/README.md @@ -6,7 +6,7 @@ I strongly believe that it is my — and your — duty to make the open While I can't force anyone to do anything, if you happen to disagree with this, I ask of you not to use any of the open source I have published. Nor am I interested in contributions from people who can't accept or act respectfully towards other humans regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. If you think feminism, anti-racism or the LGBT movement is somehow wrong, disturbing or irrelevant, I ask you to go elsewhere to find software. -Leaflet Control Geocoder [![NPM version](https://badge.fury.io/js/leaflet-control-geocoder.png)](http://badge.fury.io/js/leaflet-control-geocoder) +Leaflet Control Geocoder [![NPM version](https://img.shields.io/npm/v/leaflet-control-geocoder.svg)](https://www.npmjs.com/package/leaflet-control-geocoder) ![Leaflet 1.0.0 compatible!](https://img.shields.io/badge/Leaflet%201.0.0-%E2%9C%93-1EB300.svg?style=flat) ============================= A simple geocoder for [Leaflet](http://leafletjs.com/) that by default uses [OSM](http://www.openstreetmap.org/)/[Nominatim](http://wiki.openstreetmap.org/wiki/Nominatim). @@ -18,18 +18,24 @@ The plugin supports many different data providers: * [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/) * [Mapbox Geocoding](https://www.mapbox.com/developers/api/geocoding/) * [MapQuest Geocoding API](http://developer.mapquest.com/web/products/dev-services/geocoding-ws) -* [RaveGeo](http://www2.idevio.com/ravegeo-server.html) +* [What3Words](http://what3words.com/) +* [Photon](http://photon.komoot.de/) +* [Mapzen Search](https://mapzen.com/projects/search) +* [HERE Geocoder API] (https://developer.here.com/rest-apis/documentation/geocoder/topics/overview.html) -The plugin can easily be extended to support other providers. +The plugin can easily be extended to support other providers. Current extensions: + +* [DAWA Geocoder](https://github.com/kjoller/leaflet-control-geocoder-dawa/tree/new) - support for Danish Address Web API by [Niels Kjøller Hansen](https://github.com/kjoller) See the [Leaflet Control Geocoder Demo](http://perliedman.github.com/leaflet-control-geocoder/). # Usage -Load the CSS and Javascript: +[Download latest release](https://github.com/perliedman/leaflet-control-geocoder/releases). Load the CSS and Javascript, located in +the `dist` folder: ```HTML - + ``` @@ -46,23 +52,27 @@ L.Control.geocoder().addTo(map); # Customizing By default, when a geocoding result is found, the control will center the map on it and place -a marker at its location. This can be customized by overwriting the control's ```markGeocode``` -function, to perform any action desired. +a marker at its location. This can be customized by listening to the control's `markgeocode` +event. To remove the control's default handler for marking a result, set the option +`defaultMarkGeocode` to `false`. For example: ```javascript -var geocoder = L.Control.geocoder().addTo(map); - -geocoder.markGeocode = function(result) { - var bbox = result.bbox; - L.polygon([ - bbox.getSouthEast(), - bbox.getNorthEast(), - bbox.getNorthWest(), - bbox.getSouthWest() - ]).addTo(map); -}; +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: false + }) + .on('markgeocode', function(e) { + var bbox = e.geocode.bbox; + var poly = L.polygon([ + bbox.getSouthEast(), + bbox.getNorthEast(), + bbox.getNorthWest(), + bbox.getSouthWest() + ]).addTo(map); + map.fitBounds(poly.getBounds()); + }) + .addTo(map); ``` This will add a polygon representing the result's boundingbox when a result is selected. diff --git a/assets/control-geocoder/bower.json b/assets/control-geocoder/bower.json old mode 100644 new mode 100755 index c037d15..daf7980 --- a/assets/control-geocoder/bower.json +++ b/assets/control-geocoder/bower.json @@ -1,12 +1,17 @@ { "name": "leaflet-control-geocoder", - "version": "1.1.0", + "version": "1.5.4", "homepage": "https://github.com/perliedman/leaflet-control-geocoder", "authors": [ "Per Liedman " ], "description": "Extendable geocoder with builtin OSM/Nominatim support", - "main": "Control.Geocoder.js", + "main": [ + "Control.Geocoder.js", + "Control.Geocoder.css", + "images/geocoder.png", + "images/throbber.gif" + ], "moduleType": [ "amd", "globals" @@ -14,7 +19,16 @@ "keywords": [ "leaflet", "geocoder", - "nominatim" + "locations", + "nominatim", + "bing", + "google", + "mapbox", + "photon", + "what3words", + "mapquest", + "mapzen", + "here" ], "license": "BSD-2-Clause", "ignore": [ @@ -23,8 +37,5 @@ "bower_components", "test", "tests" - ], - "dependencies": { - "leaflet": "~0.7.2" - } + ] } diff --git a/assets/control-geocoder/package.json b/assets/control-geocoder/package.json index 020bf3b..e4e3c4d 100644 --- a/assets/control-geocoder/package.json +++ b/assets/control-geocoder/package.json @@ -1,10 +1,12 @@ { "name": "leaflet-control-geocoder", - "version": "1.1.0", - "description": "Extendable geocoder with builtin OSM/Nominatim support", - "main": "Control.Geocoder.js", + "version": "1.5.4", + "description": "Extendable geocoder with builtin support for Nominatim, Bing, Google, Mapbox, Photon, What3Words, MapQuest, Mapzen, HERE", + "main": "dist/Control.Geocoder.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "prepublish": "sh ./scripts/build.sh", + "publish": "sh ./scripts/publish.sh", + "postpublish": "sh ./scripts/postpublish.sh" }, "repository": { "type": "git", @@ -13,14 +15,30 @@ "keywords": [ "leaflet", "geocoder", - "nominatim" + "locations", + "nominatim", + "bing", + "google", + "mapbox", + "photon", + "what3words", + "mapquest", + "mapzen", + "here" ], "author": "Per Liedman ", "license": "BSD-2-Clause", "bugs": { "url": "https://github.com/perliedman/leaflet-control-geocoder/issues" }, - "dependencies": { - "leaflet": "~0.7.2" + "browserify-shim": { + "leaflet": "global:L" + }, + "dependencies": {}, + "devDependencies": { + "browserify": "^11.0.1", + "browserify-shim": "^3.8.10", + "derequire": "^2.0.3", + "es3ify": "^0.1.4" } } diff --git a/module/config/config.php b/module/config/config.php index dfaf69d..1b25ee1 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -75,7 +75,7 @@ $GLOBALS['LEAFLET_LIBRARIES']['leaflet-fullscreen'] = array $GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array ( 'name' => 'Leaflet Control Geocoder', - 'version' => '1.5.1', + 'version' => '1.5.4', 'license' => 'BSD-2-Clause', 'homepage' => 'https://github.com/perliedman/leaflet-control-geocoder', 'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css',