leaflet-geosearch icon indicating copy to clipboard operation
leaflet-geosearch copied to clipboard

Clicking on Map Address Suggestions returns error

Open sumibane opened this issue 2 years ago • 6 comments

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

sumibane avatar Oct 07 '23 20:10 sumibane

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

abumuawiyah avatar Oct 08 '23 00:10 abumuawiyah

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

Hossam-Ali avatar Oct 10 '23 16:10 Hossam-Ali

Also see #384

gjvoosten avatar Oct 11 '23 12:10 gjvoosten

works for me after downgrading to 3.9.0

TekTimmy avatar Oct 18 '23 09:10 TekTimmy

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

gjvoosten avatar Oct 18 '23 09:10 gjvoosten