Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@
const event: StartGeocodeEvent = { input: value };
this.fire(suggest ? 'startsuggest' : 'startgeocode', event);

const context = { map: this._map };
const results = suggest
? await this.options.geocoder!.suggest!(value)
: await this.options.geocoder!.geocode(value);
? await this.options.geocoder!.suggest!(value, context)

Check failure on line 321 in src/control.ts

View workflow job for this annotation

GitHub Actions / build

Expected 1 arguments, but got 2.
: await this.options.geocoder!.geocode(value, context);

Check failure on line 322 in src/control.ts

View workflow job for this annotation

GitHub Actions / build

Expected 1 arguments, but got 2.

if (requestCount === this._requestCount) {
const event: FinishGeocodeEvent = { input: value, results };
Expand Down
11 changes: 10 additions & 1 deletion src/geocoders/photon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ export class Photon implements IGeocoder {
L.Util.setOptions(this, options);
}

async geocode(query: string): Promise<GeocodingResult[]> {
async geocode(query: string, context?: { map?: L.Map }): Promise<GeocodingResult[]> {
const params = geocodingParams(this.options, { q: query });
const center = context?.map?.getCenter?.();
if (center) {
params.lat = center.lat;
params.lon = center.lng;
}
const zoom = context?.map?.getZoom?.();
if (zoom) {
params.zoom = zoom;
}
const data = await getJSON<any>(this.options.serviceUrl, params);
return this._parseResults(data);
}
Expand Down
Loading