Skip to content

Commit

Permalink
ESLint: prefer-arrow-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Dec 15, 2024
1 parent 6259608 commit b41a7fb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 53 deletions.
64 changes: 28 additions & 36 deletions src/geocoders/mapquest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,22 @@ export class MapQuest implements IGeocoder {
limit: 5,
outFormat: 'json'
});
getJSON(
this.options.serviceUrl + '/address',
params,
L.Util.bind(function (data) {
const results: GeocodingResult[] = [];
if (data.results && data.results[0].locations) {
for (let i = data.results[0].locations.length - 1; i >= 0; i--) {
const loc = data.results[0].locations[i];
const center = L.latLng(loc.latLng);
results[i] = {
name: this._formatName(loc.street, loc.adminArea4, loc.adminArea3, loc.adminArea1),
bbox: L.latLngBounds(center, center),
center: center
};
}
getJSON(this.options.serviceUrl + '/address', params, data => {
const results: GeocodingResult[] = [];
if (data.results && data.results[0].locations) {
for (let i = data.results[0].locations.length - 1; i >= 0; i--) {
const loc = data.results[0].locations[i];
const center = L.latLng(loc.latLng);
results[i] = {
name: this._formatName(loc.street, loc.adminArea4, loc.adminArea3, loc.adminArea1),
bbox: L.latLngBounds(center, center),
center: center
};
}
}

cb.call(context, results);
}, this)
);
cb.call(context, results);
});
}

reverse(location: L.LatLngLiteral, scale: number, cb: GeocodingCallback, context?: any): void {
Expand All @@ -65,26 +61,22 @@ export class MapQuest implements IGeocoder {
location: location.lat + ',' + location.lng,
outputFormat: 'json'
});
getJSON(
this.options.serviceUrl + '/reverse',
params,
L.Util.bind(function (data) {
const results: GeocodingResult[] = [];
if (data.results && data.results[0].locations) {
for (let i = data.results[0].locations.length - 1; i >= 0; i--) {
const loc = data.results[0].locations[i];
const center = L.latLng(loc.latLng);
results[i] = {
name: this._formatName(loc.street, loc.adminArea4, loc.adminArea3, loc.adminArea1),
bbox: L.latLngBounds(center, center),
center: center
};
}
getJSON(this.options.serviceUrl + '/reverse', params, data => {
const results: GeocodingResult[] = [];
if (data.results && data.results[0].locations) {
for (let i = data.results[0].locations.length - 1; i >= 0; i--) {
const loc = data.results[0].locations[i];
const center = L.latLng(loc.latLng);
results[i] = {
name: this._formatName(loc.street, loc.adminArea4, loc.adminArea3, loc.adminArea1),
bbox: L.latLngBounds(center, center),
center: center
};
}
}

cb.call(context, results);
}, this)
);
cb.call(context, results);
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/geocoders/pelias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export class Pelias implements IGeocoder {
_parseResults(data, bboxname) {
const results: GeocodingResult[] = [];
L.geoJSON(data, {
pointToLayer: function (feature, latlng) {
pointToLayer(feature, latlng) {
return L.circleMarker(latlng);
},
onEachFeature: function (feature, layer: any) {
onEachFeature(feature, layer: any) {
const result = {} as GeocodingResult;
let bbox;
let center;
Expand Down
20 changes: 6 additions & 14 deletions src/geocoders/photon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ export class Photon implements IGeocoder {

geocode(query: string, cb: GeocodingCallback, context?: any): void {
const params = geocodingParams(this.options, { q: query });
getJSON(
this.options.serviceUrl,
params,
L.Util.bind(function (data) {
cb.call(context, this._decodeFeatures(data));
}, this)
);
getJSON(this.options.serviceUrl, params, data => {
cb.call(context, this._decodeFeatures(data));
});
}

suggest(query: string, cb: GeocodingCallback, context?: any): void {
Expand All @@ -49,13 +45,9 @@ export class Photon implements IGeocoder {
lat: latLng.lat,
lon: latLng.lng
});
getJSON(
this.options.reverseUrl,
params,
L.Util.bind(function (data) {
cb.call(context, this._decodeFeatures(data));
}, this)
);
getJSON(this.options.reverseUrl, params, data => {
cb.call(context, this._decodeFeatures(data));
});
}

_decodeFeatures(data: GeoJSON.FeatureCollection<GeoJSON.Point>) {
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function getJSON(
callback: (message: any) => void
): void {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
xmlHttp.onreadystatechange = () => {
if (xmlHttp.readyState !== 4) {
return;
}
Expand Down

0 comments on commit b41a7fb

Please sign in to comment.