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

Clicking on Map Address Suggestions returns error #378

Open sumibane opened 9 months ago

sumibane commented 9 months ago

Isse Description: When start typing on the Search box and try to select an entry from the list of suggestions that shows an uncaught reference is logged in the console and the marker is not moved.

import React, { useEffect } from "react";
import { useMap } from "react-leaflet";
import { GeoSearchControl, OpenStreetMapProvider } from "leaflet-geosearch";
import "leaflet-geosearch/dist/geosearch.css";

const SearchBox: React.FC = () => {
    const map = useMap();

    useEffect(() => {
        const provider = new OpenStreetMapProvider();
        //const provider = customProvider;
        //@ts-ignore
        const searchControl = new GeoSearchControl({
            provider,
            showMarker: true,
            autoClose: false,
            notFoundMessage: "Sorry! The entered item is not found."
        });

        map.addControl(searchControl);

        return () => {
            map.removeControl(searchControl);
        };
    }, [map]);

    return null;
};

export default SearchBox;

Error: Screenshot 2023-10-08 015550

abumuawiyah commented 9 months ago

Hi, the error is due to the version of 3.10.0 (latest). To resolve it quickly until the latest got fixed, you can downgrade to the version of 3.9.0

Hossam-Ali commented 8 months ago

@abumuawiyah Hello, I can see the same issue with version 3.9.0, downgrading to 3.8.0 solved this issue.

gjvoosten commented 8 months ago

Also see #384

TekTimmy commented 8 months ago

works for me after downgrading to 3.9.0

gjvoosten commented 8 months ago

Yes, the error has been introduced in v3.10.0 through the addition of validateCoords().