mirror of
https://github.com/netzmacht/contao-leaflet-libraries.git
synced 2025-11-29 03:24:34 +01:00
Update control geocoder to v1.5.5.
This commit is contained in:
@@ -132,17 +132,19 @@ module.exports = {
|
||||
|
||||
_geocode: function(suggest) {
|
||||
var requestCount = ++this._requestCount,
|
||||
mode = suggest ? 'suggest' : 'geocode';
|
||||
mode = suggest ? 'suggest' : 'geocode',
|
||||
eventData = {input: this._input.value};
|
||||
|
||||
this._lastGeocode = this._input.value;
|
||||
if (!suggest) {
|
||||
this._clearResults();
|
||||
}
|
||||
|
||||
this.fire('start' + mode);
|
||||
this.fire('start' + mode, eventData);
|
||||
this.options.geocoder[mode](this._input.value, function(results) {
|
||||
if (requestCount === this._requestCount) {
|
||||
this.fire('finish' + mode);
|
||||
eventData.results = results;
|
||||
this.fire('finish' + mode, eventData);
|
||||
this._geocodeResult(results, suggest);
|
||||
}
|
||||
}, this);
|
||||
@@ -608,18 +610,26 @@ var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefi
|
||||
module.exports = {
|
||||
"class": L.Class.extend({
|
||||
options: {
|
||||
serviceUrl: 'https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/'
|
||||
serviceUrl: 'https://api.tiles.mapbox.com/v4/geocode/mapbox.places-v1/',
|
||||
geocodingQueryParams: {},
|
||||
reverseQueryParams: {}
|
||||
},
|
||||
|
||||
initialize: function(accessToken, options) {
|
||||
L.setOptions(this, options);
|
||||
this._accessToken = accessToken;
|
||||
this.options.geocodingQueryParams.access_token = accessToken;
|
||||
this.options.reverseQueryParams.access_token = accessToken;
|
||||
},
|
||||
|
||||
geocode: function(query, cb, context) {
|
||||
Util.getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', {
|
||||
access_token: this._accessToken
|
||||
}, function(data) {
|
||||
var params = this.options.geocodingQueryParams;
|
||||
if (typeof params.proximity !== 'undefined'
|
||||
&& params.proximity.hasOwnProperty('lat')
|
||||
&& params.proximity.hasOwnProperty('lng'))
|
||||
{
|
||||
params.proximity = params.proximity.lng + ',' + params.proximity.lat;
|
||||
}
|
||||
Util.getJSON(this.options.serviceUrl + encodeURIComponent(query) + '.json', params, function(data) {
|
||||
var results = [],
|
||||
loc,
|
||||
latLng,
|
||||
@@ -628,7 +638,7 @@ module.exports = {
|
||||
for (var i = 0; i <= data.features.length - 1; i++) {
|
||||
loc = data.features[i];
|
||||
latLng = L.latLng(loc.center.reverse());
|
||||
if(loc.hasOwnProperty('bbox'))
|
||||
if (loc.hasOwnProperty('bbox'))
|
||||
{
|
||||
latLngBounds = L.latLngBounds(L.latLng(loc.bbox.slice(0, 2).reverse()), L.latLng(loc.bbox.slice(2, 4).reverse()));
|
||||
}
|
||||
@@ -653,9 +663,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
reverse: function(location, scale, cb, context) {
|
||||
Util.getJSON(this.options.serviceUrl + encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat) + '.json', {
|
||||
access_token: this._accessToken
|
||||
}, function(data) {
|
||||
Util.getJSON(this.options.serviceUrl + encodeURIComponent(location.lng) + ',' + encodeURIComponent(location.lat) + '.json', this.options.reverseQueryParams, function(data) {
|
||||
var results = [],
|
||||
loc,
|
||||
latLng,
|
||||
@@ -664,7 +672,7 @@ module.exports = {
|
||||
for (var i = 0; i <= data.features.length - 1; i++) {
|
||||
loc = data.features[i];
|
||||
latLng = L.latLng(loc.center.reverse());
|
||||
if(loc.hasOwnProperty('bbox'))
|
||||
if (loc.hasOwnProperty('bbox'))
|
||||
{
|
||||
latLngBounds = L.latLngBounds(L.latLng(loc.bbox.slice(0, 2).reverse()), L.latLng(loc.bbox.slice(2, 4).reverse()));
|
||||
}
|
||||
@@ -1043,6 +1051,9 @@ module.exports = {
|
||||
|
||||
results.push({
|
||||
name: this._deocodeFeatureName(f),
|
||||
html: this.options.htmlTemplate ?
|
||||
this.options.htmlTemplate(f)
|
||||
: undefined,
|
||||
center: latLng,
|
||||
bbox: bbox,
|
||||
properties: f.properties
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -160,7 +160,7 @@ An object that represents a result from a geocoding query.
|
||||
| Property | Type | Description |
|
||||
| ---------- | ---------------- | ------------------------------------- |
|
||||
| name | String | Name of found location |
|
||||
| bounds | L.LatLngBounds | The bounds of the location |
|
||||
| bbox | L.LatLngBounds | The bounds of the location |
|
||||
| center | L.LatLng | The center coordinate of the location |
|
||||
| icon | String | URL for icon representing result; optional |
|
||||
| html | String | (optional) HTML formatted representation of the name |
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "leaflet-control-geocoder",
|
||||
"version": "1.5.4",
|
||||
"version": "1.5.5",
|
||||
"homepage": "https://github.com/perliedman/leaflet-control-geocoder",
|
||||
"authors": [
|
||||
"Per Liedman <per@liedman.net>"
|
||||
],
|
||||
"description": "Extendable geocoder with builtin OSM/Nominatim support",
|
||||
"main": [
|
||||
"Control.Geocoder.js",
|
||||
"Control.Geocoder.css",
|
||||
"dist/Control.Geocoder.js",
|
||||
"dist/Control.Geocoder.css",
|
||||
"images/geocoder.png",
|
||||
"images/throbber.gif"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "leaflet-control-geocoder",
|
||||
"version": "1.5.4",
|
||||
"version": "1.5.5",
|
||||
"description": "Extendable geocoder with builtin support for Nominatim, Bing, Google, Mapbox, Photon, What3Words, MapQuest, Mapzen, HERE",
|
||||
"main": "dist/Control.Geocoder.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user