smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.02k stars 271 forks source link

Module '"...@types/leaflet/index"' has no default export. #293

Closed gregarega1993 closed 2 years ago

gregarega1993 commented 2 years ago

Hi @smeijer you have an issue in SearchControl.d.ts

Adjusting it to this makes it work in Angular:

import * as L from 'leaflet';
import SearchElement from './SearchElement';
import ResultList from './resultList';
import { SearchResult } from './providers/provider';
import { Provider } from './providers';
interface SearchControlProps {
    /** the provider to use for searching */
    provider: Provider;
    /** the leaflet position to render the element in */
    position: L.ControlPosition;
    /**
     * the stye of the search element
     * @default bar
     **/
    style: 'button' | 'bar';
    marker: L.MarkerOptions;
    maxMarkers: number;
    showMarker: boolean;
    showPopup: boolean;
    popupFormat<T = any>(args: {
        query: Selection;
        result: SearchResult<T>;
    }): string;
    resultFormat<T = any>(args: {
        result: SearchResult<T>;
    }): string;
    searchLabel: string;
    notFoundMessage: string;
    messageHideDelay: number;
    animateZoom: boolean;
    zoomLevel: number;
    retainZoomLevel: boolean;
    classNames: {
        container: string;
        button: string;
        resetButton: string;
        msgbox: string;
        form: string;
        input: string;
        resultlist: string;
        item: string;
        notfound: string;
    };
    autoComplete: boolean;
    autoCompleteDelay: number;
    maxSuggestions: number;
    autoClose: boolean;
    keepResult: boolean;
    updateMap: boolean;
}
export declare type SearchControlOptions = Partial<SearchControlProps> & {
    provider: Provider;
};
interface Selection {
    query: string;
    data?: SearchResult;
}
interface SearchControl {
    options: Omit<SearchControlProps, 'provider'> & {
        provider?: SearchControlProps['provider'];
    };
    markers: L.FeatureGroup;
    searchElement: SearchElement;
    resultList: ResultList;
    classNames: SearchControlProps['classNames'];
    container: HTMLDivElement;
    input: HTMLInputElement;
    button: HTMLAnchorElement;
    resetButton: HTMLAnchorElement;
    map: L.Map;
    initialize(options: SearchControlProps): void;
    onSubmit(result: Selection): void;
    onClick(event: Event): void;
    clearResults(event?: KeyboardEvent | null, force?: boolean): void;
    autoSearch(event: KeyboardEvent): void;
    selectResult(event: KeyboardEvent): void;
    showResult(result: SearchResult, query: Selection): void;
    addMarker(result: SearchResult, selection: Selection): void;
    centerMap(result: SearchResult): void;
    closeResults(): void;
    getZoom(): number;
    onAdd(map: L.Map): HTMLDivElement;
    onRemove(): SearchControl;
}
export default function SearchControl(...options: any[]): SearchControl & L.Control;
export {};

Should I submit a PR for this?

smeijer commented 2 years ago

I'm not sure what the change is that you're proposing. Do you mean the return type for SearchControl?

gregarega1993 commented 2 years ago

I'm not sure what the change is that you're proposing. Do you mean the return type for SearchControl?

This can be closed, I see that it was merged yesterday here :) https://github.com/smeijer/leaflet-geosearch/pull/285