diff --git a/public/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js b/public/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js index 8d034163a7f91708a037e11e4310aa13f535f481..9a7b3331dfea564f3070dd1a0a8de33c1e32be49 100644 --- a/public/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js +++ b/public/resources/leaflet-control-geocoder-1.13.0/Control.Geocoder.js @@ -64,7 +64,7 @@ this.L.Control.Geocoder = (function (L) { function getJSON(url, params, callback) { var xmlHttp = new XMLHttpRequest(); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState !== 4) { return; } @@ -91,7 +91,7 @@ this.L.Control.Geocoder = (function (L) { } function template(str, data) { - return str.replace(/\{ *([\w_]+) *\}/g, function(str, key) { + return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) { var value = data[key]; if (value === undefined) { value = ''; @@ -123,12 +123,12 @@ this.L.Control.Geocoder = (function (L) { service_url: 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer' }, - initialize: function(accessToken, options) { + initialize: function (accessToken, options) { L.setOptions(this, options); this._accessToken = accessToken; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = { SingleLine: query, outFields: 'Addr_Type', @@ -144,7 +144,7 @@ this.L.Control.Geocoder = (function (L) { getJSON( this.options.service_url + '/findAddressCandidates', L.extend(params, this.options.geocodingQueryParams), - function(data) { + function (data) { var results = [], loc, latLng, @@ -171,18 +171,18 @@ this.L.Control.Geocoder = (function (L) { ); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { var params = { location: encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat), distance: 100, f: 'json' }; - getJSON(this.options.service_url + '/reverseGeocode', params, function(data) { + getJSON(this.options.service_url + '/reverseGeocode', params, function (data) { var result = [], loc; @@ -205,18 +205,18 @@ this.L.Control.Geocoder = (function (L) { } var Bing = L.Class.extend({ - initialize: function(key) { + initialize: function (key) { this.key = key; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { jsonp( 'https://dev.virtualearth.net/REST/v1/Locations', { query: query, key: this.key }, - function(data) { + function (data) { var results = []; if (data.resourceSets.length > 0) { for (var i = data.resourceSets[0].resources.length - 1; i >= 0; i--) { @@ -236,13 +236,13 @@ this.L.Control.Geocoder = (function (L) { ); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { jsonp( '//dev.virtualearth.net/REST/v1/Locations/' + location.lat + ',' + location.lng, { key: this.key }, - function(data) { + function (data) { var results = []; for (var i = data.resourceSets[0].resources.length - 1; i >= 0; i--) { var resource = data.resourceSets[0].resources[i], @@ -272,14 +272,14 @@ this.L.Control.Geocoder = (function (L) { reverseQueryParams: {} }, - initialize: function(key, options) { + initialize: function (key, options) { this._key = key; L.setOptions(this, options); // Backwards compatibility this.options.serviceUrl = this.options.service_url || this.options.serviceUrl; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = { address: query }; @@ -290,7 +290,7 @@ this.L.Control.Geocoder = (function (L) { params = L.Util.extend(params, this.options.geocodingQueryParams); - getJSON(this.options.serviceUrl, params, function(data) { + getJSON(this.options.serviceUrl, params, function (data) { var results = [], loc, latLng, @@ -316,7 +316,7 @@ this.L.Control.Geocoder = (function (L) { }); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { var params = { latlng: encodeURIComponent(location.lat) + ',' + encodeURIComponent(location.lng) }; @@ -325,7 +325,7 @@ this.L.Control.Geocoder = (function (L) { params.key = this._key; } - getJSON(this.options.serviceUrl, params, function(data) { + getJSON(this.options.serviceUrl, params, function (data) { var results = [], loc, latLng, @@ -366,10 +366,10 @@ this.L.Control.Geocoder = (function (L) { reverseQueryParams: {}, reverseGeocodeProxRadius: null }, - initialize: function(options) { + initialize: function (options) { L.setOptions(this, options); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = { searchtext: query, gen: 9, @@ -380,7 +380,7 @@ this.L.Control.Geocoder = (function (L) { params = L.Util.extend(params, this.options.geocodingQueryParams); this.getJSON(this.options.geocodeUrl, params, cb, context); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { var _proxRadius = this.options.reverseGeocodeProxRadius ? this.options.reverseGeocodeProxRadius : null; @@ -396,8 +396,8 @@ this.L.Control.Geocoder = (function (L) { params = L.Util.extend(params, this.options.reverseQueryParams); this.getJSON(this.options.reverseGeocodeUrl, params, cb, context); }, - getJSON: function(url, params, cb, context) { - getJSON(url, params, function(data) { + getJSON: function (url, params, cb, context) { + getJSON(url, params, function (data) { var results = [], loc, latLng, @@ -433,11 +433,11 @@ this.L.Control.Geocoder = (function (L) { sizeInMeters: 10000 }, - initialize: function(options) { + initialize: function (options) { L.Util.setOptions(this, options); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var match; var center; // regex from https://github.com/openstreetmap/openstreetmap-website/blob/master/app/controllers/geocoder_controller.rb @@ -483,9 +483,9 @@ this.L.Control.Geocoder = (function (L) { // [NSEW] degrees, minutes, decimal seconds center = L.latLng( (/N/i.test(match[1]) ? 1 : -1) * - (parseFloat(match[2]) + parseFloat(match[3] / 60 + parseFloat(match[4] / 3600))), + (parseFloat(match[2]) + parseFloat(match[3] / 60 + parseFloat(match[4] / 3600))), (/E/i.test(match[5]) ? 1 : -1) * - (parseFloat(match[6]) + parseFloat(match[7] / 60) + parseFloat(match[8] / 3600)) + (parseFloat(match[6]) + parseFloat(match[7] / 60) + parseFloat(match[8] / 3600)) ); } else if ( (match = query.match( @@ -495,9 +495,9 @@ this.L.Control.Geocoder = (function (L) { // degrees, minutes, decimal seconds [NSEW] center = L.latLng( (/N/i.test(match[4]) ? 1 : -1) * - (parseFloat(match[1]) + parseFloat(match[2] / 60 + parseFloat(match[3] / 3600))), + (parseFloat(match[1]) + parseFloat(match[2] / 60 + parseFloat(match[3] / 3600))), (/E/i.test(match[8]) ? 1 : -1) * - (parseFloat(match[5]) + parseFloat(match[6] / 60) + parseFloat(match[7] / 3600)) + (parseFloat(match[5]) + parseFloat(match[6] / 60) + parseFloat(match[7] / 3600)) ); } else if ( (match = query.match(/^\s*([+-]?\d+(?:\.\d*)?)\s*[\s,]\s*([+-]?\d+(?:\.\d*)?)\s*$/)) @@ -530,13 +530,13 @@ this.L.Control.Geocoder = (function (L) { reverseQueryParams: {} }, - initialize: function(accessToken, options) { + initialize: function (accessToken, options) { L.setOptions(this, options); this.options.geocodingQueryParams.access_token = accessToken; this.options.reverseQueryParams.access_token = accessToken; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = this.options.geocodingQueryParams; if ( params.proximity !== undefined && @@ -545,7 +545,7 @@ this.L.Control.Geocoder = (function (L) { ) { params.proximity = params.proximity.lng + ',' + params.proximity.lat; } - getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', params, function(data) { + getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', params, function (data) { var results = [], loc, latLng, @@ -591,19 +591,19 @@ this.L.Control.Geocoder = (function (L) { }); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { getJSON( this.options.serviceUrl + - encodeURIComponent(location.lng) + - ',' + - encodeURIComponent(location.lat) + - '.json', + encodeURIComponent(location.lng) + + ',' + + encodeURIComponent(location.lat) + + '.json', this.options.reverseQueryParams, - function(data) { + function (data) { var results = [], loc, latLng, @@ -643,7 +643,7 @@ this.L.Control.Geocoder = (function (L) { serviceUrl: 'https://www.mapquestapi.com/geocoding/v1' }, - initialize: function(key, options) { + initialize: function (key, options) { // MapQuest seems to provide URI encoded API keys, // so to avoid encoding them twice, we decode them here this._key = decodeURIComponent(key); @@ -651,7 +651,7 @@ this.L.Control.Geocoder = (function (L) { L.Util.setOptions(this, options); }, - _formatName: function() { + _formatName: function () { var r = [], i; for (i = 0; i < arguments.length; i++) { @@ -663,7 +663,7 @@ this.L.Control.Geocoder = (function (L) { return r.join(', '); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { getJSON( this.options.serviceUrl + '/address', { @@ -672,7 +672,7 @@ this.L.Control.Geocoder = (function (L) { limit: 5, outFormat: 'json' }, - L.bind(function(data) { + L.bind(function (data) { var results = [], loc, latLng; @@ -693,7 +693,7 @@ this.L.Control.Geocoder = (function (L) { ); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { getJSON( this.options.serviceUrl + '/reverse', { @@ -701,7 +701,7 @@ this.L.Control.Geocoder = (function (L) { location: location.lat + ',' + location.lng, outputFormat: 'json' }, - L.bind(function(data) { + L.bind(function (data) { var results = [], loc, latLng; @@ -734,12 +734,12 @@ this.L.Control.Geocoder = (function (L) { serviceUrl: 'https://neutrinoapi.com/' }, - initialize: function(options) { + initialize: function (options) { L.Util.setOptions(this, options); }, // https://www.neutrinoapi.com/api/geocode-address/ - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { getJSON( this.options.serviceUrl + 'geocode-address', { @@ -748,7 +748,7 @@ this.L.Control.Geocoder = (function (L) { //get three words and make a dot based string address: query.split(/\s+/).join('.') }, - function(data) { + function (data) { var results = [], latLng, latLngBounds; @@ -768,12 +768,12 @@ this.L.Control.Geocoder = (function (L) { ); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, // https://www.neutrinoapi.com/api/geocode-reverse/ - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { getJSON( this.options.serviceUrl + 'geocode-reverse', { @@ -782,7 +782,7 @@ this.L.Control.Geocoder = (function (L) { latitude: location.lat, longitude: location.lng }, - function(data) { + function (data) { var results = [], latLng, latLngBounds; @@ -810,7 +810,7 @@ this.L.Control.Geocoder = (function (L) { serviceUrl: 'https://nominatim.openstreetmap.org/', geocodingQueryParams: {}, reverseQueryParams: {}, - htmlTemplate: function(r) { + htmlTemplate: function (r) { var a = r.address, className, parts = []; @@ -834,11 +834,11 @@ this.L.Control.Geocoder = (function (L) { } }, - initialize: function(options) { + initialize: function (options) { L.Util.setOptions(this, options); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { getJSON( this.options.serviceUrl + 'search', L.extend( @@ -850,7 +850,7 @@ this.L.Control.Geocoder = (function (L) { }, this.options.geocodingQueryParams ), - L.bind(function(data) { + L.bind(function (data) { var results = []; for (var i = data.length - 1; i >= 0; i--) { var bbox = data[i].boundingbox; @@ -871,9 +871,9 @@ this.L.Control.Geocoder = (function (L) { suggest: function (query, cb, context) { return this.geocode(query, cb, context); - }, + }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { getJSON( this.options.serviceUrl + 'reverse', L.extend( @@ -886,7 +886,7 @@ this.L.Control.Geocoder = (function (L) { }, this.options.reverseQueryParams ), - L.bind(function(data) { + L.bind(function (data) { var result = [], loc; @@ -917,11 +917,11 @@ this.L.Control.Geocoder = (function (L) { codeLength: undefined }, - initialize: function(options) { + initialize: function (options) { L.setOptions(this, options); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { try { var decoded = this.options.OpenLocationCode.decode(query); var result = { @@ -938,7 +938,7 @@ this.L.Control.Geocoder = (function (L) { cb.call(context, []); } }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { try { var code = this.options.OpenLocationCode.encode( location.lat, @@ -972,18 +972,18 @@ this.L.Control.Geocoder = (function (L) { reverseQueryParams: {} }, - initialize: function(apiKey, options) { + initialize: function (apiKey, options) { L.setOptions(this, options); this._accessToken = apiKey; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = { key: this._accessToken, q: query }; params = L.extend(params, this.options.geocodingQueryParams); - getJSON(this.options.serviceUrl, params, function(data) { + getJSON(this.options.serviceUrl, params, function (data) { var results = [], latLng, latLngBounds, @@ -1011,17 +1011,17 @@ this.L.Control.Geocoder = (function (L) { }); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { var params = { key: this._accessToken, q: [location.lat, location.lng].join(',') }; params = L.extend(params, this.options.reverseQueryParams); - getJSON(this.options.serviceUrl, params, function(data) { + getJSON(this.options.serviceUrl, params, function (data) { var results = [], latLng, latLngBounds, @@ -1061,13 +1061,13 @@ this.L.Control.Geocoder = (function (L) { reverseQueryParams: {} }, - initialize: function(apiKey, options) { + initialize: function (apiKey, options) { L.Util.setOptions(this, options); this._apiKey = apiKey; this._lastSuggest = 0; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var _this = this; getJSON( this.options.serviceUrl + '/search', @@ -1078,13 +1078,13 @@ this.L.Control.Geocoder = (function (L) { }, this.options.geocodingQueryParams ), - function(data) { + function (data) { cb.call(context, _this._parseResults(data, 'bbox')); } ); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { var _this = this; getJSON( this.options.serviceUrl + '/autocomplete', @@ -1095,7 +1095,7 @@ this.L.Control.Geocoder = (function (L) { }, this.options.geocodingQueryParams ), - L.bind(function(data) { + L.bind(function (data) { if (data.geocoding.timestamp > this._lastSuggest) { this._lastSuggest = data.geocoding.timestamp; cb.call(context, _this._parseResults(data, 'bbox')); @@ -1104,7 +1104,7 @@ this.L.Control.Geocoder = (function (L) { ); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { var _this = this; getJSON( this.options.serviceUrl + '/reverse', @@ -1116,19 +1116,19 @@ this.L.Control.Geocoder = (function (L) { }, this.options.reverseQueryParams ), - function(data) { + function (data) { cb.call(context, _this._parseResults(data, 'bounds')); } ); }, - _parseResults: function(data, bboxname) { + _parseResults: function (data, bboxname) { var results = []; L.geoJson(data, { - pointToLayer: function(feature, latlng) { + pointToLayer: function (feature, latlng) { return L.circleMarker(latlng); }, - onEachFeature: function(feature, layer) { + onEachFeature: function (feature, layer) { var result = {}, bbox, center; @@ -1183,11 +1183,11 @@ this.L.Control.Geocoder = (function (L) { nameProperties: ['name', 'street', 'suburb', 'hamlet', 'town', 'city', 'state', 'country'] }, - initialize: function(options) { + initialize: function (options) { L.setOptions(this, options); }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { var params = L.extend( { q: query @@ -1198,17 +1198,17 @@ this.L.Control.Geocoder = (function (L) { getJSON( this.options.serviceUrl, params, - L.bind(function(data) { + L.bind(function (data) { cb.call(context, this._decodeFeatures(data)); }, this) ); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, - reverse: function(latLng, scale, cb, context) { + reverse: function (latLng, scale, cb, context) { var params = L.extend( { lat: latLng.lat, @@ -1220,13 +1220,13 @@ this.L.Control.Geocoder = (function (L) { getJSON( this.options.reverseUrl, params, - L.bind(function(data) { + L.bind(function (data) { cb.call(context, this._decodeFeatures(data)); }, this) ); }, - _decodeFeatures: function(data) { + _decodeFeatures: function (data) { var results = [], i, f, @@ -1261,12 +1261,12 @@ this.L.Control.Geocoder = (function (L) { return results; }, - _decodeFeatureName: function(f) { + _decodeFeatureName: function (f) { return (this.options.nameProperties || []) - .map(function(p) { + .map(function (p) { return f.properties[p]; }) - .filter(function(v) { + .filter(function (v) { return !!v; }) .join(', '); @@ -1278,135 +1278,135 @@ this.L.Control.Geocoder = (function (L) { } const TYPE_LABEL = { - housenumber: 'Numéro', - street: 'Rue', - locality: 'Lieux-dit', - municipality: 'Commune', + housenumber: 'Numéro', + street: 'Rue', + locality: 'Lieux-dit', + municipality: 'Commune', }; var AddOk = L.Class.extend({ - options: { - serviceUrl: 'https://api-adresse.data.gouv.fr', - limit: 5, - htmlTemplate: function (r) { - var parts = []; - - /* some available classes: - leaflet-control-geocoder-address-detail - leaflet-control-geocoder-address-context - */ - parts.push('<span class="leaflet-control-geocoder-address-item"> {label} </span>({type})<span>' + '</span>'); - parts.push('<span class="' + (parts.length > 0 ? 'leaflet-control-geocoder-address-detail' : '') + - '">{context}</span>'); - - return template(parts.join('<br/>'), r); + options: { + serviceUrl: 'https://api-adresse.data.gouv.fr', + limit: 5, + htmlTemplate: function (r) { + var parts = []; + + /* some available classes: + leaflet-control-geocoder-address-detail + leaflet-control-geocoder-address-context + */ + parts.push('<span class="leaflet-control-geocoder-address-item"> {label} </span>({type})<span>' + '</span>'); + parts.push('<span class="' + (parts.length > 0 ? 'leaflet-control-geocoder-address-detail' : '') + + '">{context}</span>'); + + return template(parts.join('<br/>'), r); + } + + }, + + initialize: function (options) { + L.setOptions(this, options); + }, + + geocode: function (query, cb, context) { + + var params = L.extend({ + q: query, + limit: this.options.limit + }, this.options.geocodingQueryParams); + var that = this; + + getJSON(this.options.serviceUrl + '/search/', params, function (data) { + var results = [], + i, + f, + c, + latLng, + extent, + bbox; + if (data && data.features) { + for (i = 0; i < data.features.length; i++) { + f = data.features[i]; + c = f.geometry.coordinates; + latLng = L.latLng(c[1], c[0]); + extent = f.properties.extent; + + if (extent) { + bbox = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]); + } else { + bbox = L.latLngBounds(latLng, latLng); + } + + // Translate the type in french + if (f.properties.type) { + f.properties.type = TYPE_LABEL[f.properties.type]; + } + + results.push({ + name: f.properties.name, + center: latLng, + bbox: bbox, + html: that.options.htmlTemplate ? + that.options.htmlTemplate(f.properties) + : undefined + }); } + } - }, - - initialize: function (options) { - L.setOptions(this, options); - }, - - geocode: function (query, cb, context) { - - var params = L.extend({ - q: query, - limit: this.options.limit - }, this.options.geocodingQueryParams); - var that = this; - - getJSON(this.options.serviceUrl + '/search/', params, function (data) { - var results = [], - i, - f, - c, - latLng, - extent, - bbox; - if (data && data.features) { - for (i = 0; i < data.features.length; i++) { - f = data.features[i]; - c = f.geometry.coordinates; - latLng = L.latLng(c[1], c[0]); - extent = f.properties.extent; - - if (extent) { - bbox = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]); - } else { - bbox = L.latLngBounds(latLng, latLng); - } - - // Translate the type in french - if (f.properties.type) { - f.properties.type = TYPE_LABEL[f.properties.type]; - } - - results.push({ - name: f.properties.name, - center: latLng, - bbox: bbox, - html: that.options.htmlTemplate ? - that.options.htmlTemplate(f.properties) - : undefined - }); - } - } + cb.call(context, results); + }); + }, - cb.call(context, results); - }); - }, - - suggest: function (query, cb, context) { - return this.geocode(query, cb, context); - }, - - reverse: function (location, scale, cb, context) { - var params = L.extend({ - lat: location.lat, - lon: location.lng - }, this.options.reverseQueryParams); - var that = this; - getJSON(this.options.serviceUrl + '/reverse/', params, function (data) { - var results = [], - i, - f, - c, - latLng, - extent, - bbox; - if (data && data.features) { - for (i = 0; i < data.features.length; i++) { - f = data.features[i]; - c = f.geometry.coordinates; - latLng = L.latLng(c[1], c[0]); - extent = f.properties.extent; - - if (extent) { - bbox = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]); - } else { - bbox = L.latLngBounds(latLng, latLng); - } - - results.push({ - name: f.properties.name, - center: latLng, - bbox: bbox, - html: that.options.htmlTemplate ? - that.options.htmlTemplate(f.properties) - : undefined - }); - } - } + suggest: function (query, cb, context) { + return this.geocode(query, cb, context); + }, - cb.call(context, results); - }); - } + reverse: function (location, scale, cb, context) { + var params = L.extend({ + lat: location.lat, + lon: location.lng + }, this.options.reverseQueryParams); + var that = this; + getJSON(this.options.serviceUrl + '/reverse/', params, function (data) { + var results = [], + i, + f, + c, + latLng, + extent, + bbox; + if (data && data.features) { + for (i = 0; i < data.features.length; i++) { + f = data.features[i]; + c = f.geometry.coordinates; + latLng = L.latLng(c[1], c[0]); + extent = f.properties.extent; + + if (extent) { + bbox = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]); + } else { + bbox = L.latLngBounds(latLng, latLng); + } + + results.push({ + name: f.properties.name, + center: latLng, + bbox: bbox, + html: that.options.htmlTemplate ? + that.options.htmlTemplate(f.properties) + : undefined + }); + } + } + + cb.call(context, results); + }); + } }); function addok(key) { - return new AddOk(key); + return new AddOk(key); } var What3Words = L.Class.extend({ @@ -1414,11 +1414,11 @@ this.L.Control.Geocoder = (function (L) { serviceUrl: 'https://api.what3words.com/v2/' }, - initialize: function(accessToken) { + initialize: function (accessToken) { this._accessToken = accessToken; }, - geocode: function(query, cb, context) { + geocode: function (query, cb, context) { //get three words and make a dot based string getJSON( this.options.serviceUrl + 'forward', @@ -1426,7 +1426,7 @@ this.L.Control.Geocoder = (function (L) { key: this._accessToken, addr: query.split(/\s+/).join('.') }, - function(data) { + function (data) { var results = [], latLng, latLngBounds; @@ -1445,18 +1445,18 @@ this.L.Control.Geocoder = (function (L) { ); }, - suggest: function(query, cb, context) { + suggest: function (query, cb, context) { return this.geocode(query, cb, context); }, - reverse: function(location, scale, cb, context) { + reverse: function (location, scale, cb, context) { getJSON( this.options.serviceUrl + 'reverse', { key: this._accessToken, coords: [location.lat, location.lng].join(',') }, - function(data) { + function (data) { var results = [], latLng, latLngBounds; @@ -1537,7 +1537,7 @@ this.L.Control.Geocoder = (function (L) { includes: L.Evented.prototype || L.Mixin.Events, - initialize: function(options) { + initialize: function (options) { L.Util.setOptions(this, options); if (!this.options.geocoder) { this.options.geocoder = new Nominatim(); @@ -1546,15 +1546,15 @@ this.L.Control.Geocoder = (function (L) { this._requestCount = 0; }, - addThrobberClass: function() { + addThrobberClass: function () { L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-throbber'); }, - removeThrobberClass: function() { + removeThrobberClass: function () { L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-throbber'); }, - onAdd: function(map) { + onAdd: function (map) { var className = 'leaflet-control-geocoder', container = L.DomUtil.create('div', className + ' leaflet-bar'), icon = L.DomUtil.create('button', className + '-icon', container), @@ -1591,7 +1591,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.addListener( input, 'blur', - function() { + function () { if (this.options.collapsed && !this._preventBlurCollapse) { this._collapse(); } @@ -1605,7 +1605,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.addListener( container, 'click', - function(e) { + function (e) { if (e.button === 0 && e.detail !== 2) { this._toggle(); } @@ -1616,7 +1616,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.addListener( container, L.Browser.touch ? 'touchstart mousedown' : 'mousedown', - function(e) { + function (e) { this._toggle(); e.preventDefault(); // mobile: clicking focuses the icon, so UI expands and immediately collapses e.stopPropagation(); @@ -1634,7 +1634,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.addListener( container, 'touchstart', - function() { + function () { this._geocode(); }, this @@ -1643,7 +1643,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.addListener( container, 'click', - function() { + function () { this._geocode(); }, this @@ -1665,12 +1665,12 @@ this.L.Control.Geocoder = (function (L) { return container; }, - setQuery: function(string) { + setQuery: function (string) { this._input.value = string; return this; }, - _geocodeResult: function(results, suggest) { + _geocodeResult: function (results, suggest) { if (!suggest && this.options.showUniqueResult && results.length === 1) { this._geocodeResultSelected(results[0]); } else if (results.length > 0) { @@ -1687,7 +1687,7 @@ this.L.Control.Geocoder = (function (L) { } }, - markGeocode: function(result) { + markGeocode: function (result) { result = result.geocode || result; this._map.fitBounds(result.bbox); @@ -1696,7 +1696,18 @@ this.L.Control.Geocoder = (function (L) { this._map.removeLayer(this._geocodeMarker); } - this._geocodeMarker = new L.Marker(result.center) + const CustomIcon = L.Icon.extend({ //* recreate leaflet default icon, because not working out of box, reason not found + options: { + iconUrl: "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55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UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC", + iconSize: [25, 41], + iconAnchor: [12.5, 41], + popupAnchor: [0, -40] + } + }); + const icon = new CustomIcon() + + this._geocodeMarker = new L.Marker(result.center, { icon }) .bindPopup(result.html || result.name) .addTo(this._map) .openPopup(); @@ -1704,7 +1715,7 @@ this.L.Control.Geocoder = (function (L) { return this; }, - _geocode: function(suggest) { + _geocode: function (suggest) { var value = this._input.value; if (!suggest && value.length < this.options.queryMinLength) { return; @@ -1722,7 +1733,7 @@ this.L.Control.Geocoder = (function (L) { this.fire('start' + mode, eventData); this.options.geocoder[mode]( value, - function(results) { + function (results) { if (requestCount === this._requestCount) { eventData.results = results; this.fire('finish' + mode, eventData); @@ -1733,11 +1744,11 @@ this.L.Control.Geocoder = (function (L) { ); }, - _geocodeResultSelected: function(result) { + _geocodeResultSelected: function (result) { this.fire('markgeocode', { geocode: result }); }, - _toggle: function() { + _toggle: function () { if (L.DomUtil.hasClass(this._container, 'leaflet-control-geocoder-expanded')) { this._collapse(); } else { @@ -1745,13 +1756,13 @@ this.L.Control.Geocoder = (function (L) { } }, - _expand: function() { + _expand: function () { L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-expanded'); this._input.select(); this.fire('expand'); }, - _collapse: function() { + _collapse: function () { L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-expanded'); L.DomUtil.addClass(this._alts, 'leaflet-control-geocoder-alternatives-minimized'); L.DomUtil.removeClass(this._errorElement, 'leaflet-control-geocoder-error'); @@ -1761,7 +1772,7 @@ this.L.Control.Geocoder = (function (L) { this.fire('collapse'); }, - _clearResults: function() { + _clearResults: function () { L.DomUtil.addClass(this._alts, 'leaflet-control-geocoder-alternatives-minimized'); this._selection = null; L.DomUtil.removeClass(this._errorElement, 'leaflet-control-geocoder-error'); @@ -1769,7 +1780,7 @@ this.L.Control.Geocoder = (function (L) { L.DomUtil.removeClass(this._container, 'leaflet-control-geocoder-options-error'); }, - _createAlt: function(result, index) { + _createAlt: function (result, index) { var li = L.DomUtil.create('li', ''), a = L.DomUtil.create('a', '', li), icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null, @@ -1786,7 +1797,7 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.on( li, 'click touchend', - function() { + function () { if (this.options.collapsed) { this._collapse(); } else { @@ -1817,7 +1828,7 @@ this.L.Control.Geocoder = (function (L) { return li; }, - _keydown: function(e) { + _keydown: function (e) { var _this = this, select = function select(dir) { if (_this._selection) { @@ -1866,13 +1877,13 @@ this.L.Control.Geocoder = (function (L) { L.DomEvent.preventDefault(e); }, - _change: function() { + _change: function () { var v = this._input.value; if (v !== this._lastGeocode) { clearTimeout(this._suggestTimeout); if (v.length >= this.options.suggestMinLength) { this._suggestTimeout = setTimeout( - L.bind(function() { + L.bind(function () { this._geocode(true); }, this), this.options.suggestTimeout