smeijer / leaflet-geosearch

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

n.search is not a function in custom provider #373

Closed KaungHtet-Naing closed 10 months ago

KaungHtet-Naing commented 10 months ago

I don't know why it always shows this error in my custom provider if anyone has an idea what I'm facing pls give me a hand. 🙏 Unhandled Runtime Error TypeError: n.search is not a function

Screen Shot 2023-08-29 at 3 37 26 PM
class MyProvider extends OpenStreetMapProvider {
    endpoint({ query }) {
        return this.getUrl(
            `https://developers.onemap.sg/commonapi/search?searchVal=${query}&returnGeom=Y&getAddrDetails=Y&pageNum=1`
        );
    }
    parse(response) {
        console.log(response);
        return response;
    }
}
KaungHtet-Naing commented 10 months ago

sorry i got the answers it is my false i forget new keyword in

const searchControl = new GeoSearchControl({
        notFoundMessage: "Sorry, that address could not be found.",
        provider: new MyProvider(),
        style: "button",
        autoComplete: true,
        autoCompleteDelay: 250,
        marker: {
            icon: new L.Icon.Default(),
            draggable: false,
        },
    });