Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONP broken #321

Closed
svbatalov opened this issue Mar 30, 2023 · 2 comments · Fixed by #322 · May be fixed by #326
Closed

JSONP broken #321

svbatalov opened this issue Mar 30, 2023 · 2 comments · Fixed by #322 · May be fixed by #326

Comments

@svbatalov
Copy link
Contributor

Hello.

I query OSM Nominatim API via JSONP callback. Few months ago it stopped working -- whenever I try to search something, the following error is thrown:

Uncaught TypeError: L.Control.Search.callJsonp is not a function

After some investigation it turns out that recent versions call _retrieveData directly instead of using this._retrieveData.call(...), as it was before. So instead of 2 arguments (inputText and callback) the function is called with three, so inputText = this and callback = inputText.

svbatalov added a commit to svbatalov/leaflet-search that referenced this issue Mar 30, 2023
@svbatalov
Copy link
Contributor Author

Created PR #322 that should fix this.

@jt196
Copy link

jt196 commented Jun 2, 2023

So, hacking around a bit with this code and the PR this last day or two. The PR does stop the error, but the search results produce an "undefined" result in the search box. I've tested this by changing the source code on the example online as well as my personal project.

Screenshot 2023-06-02 at 10 54 22

If it's any help, this is the request URL: https://nominatim.openstreetmap.org/search?format=json&q=London&json_callback=L.Control.Search.callJsonp

And this is the response:

L.Control.Search.callJsonp([{
    "place_id": 344385499,
    "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
    "osm_type": "relation",
    "osm_id": 65606,
    "boundingbox": ["51.2867601", "51.6918741", "-0.5103751", "0.3340155"],
    "lat": "51.5073359",
    "lon": "-0.12765",
    "display_name": "London, Greater London, England, United Kingdom",
    "class": "place",
    "type": "city",
    "importance": 0.9407827616237295,
    "icon": "https://nominatim.openstreetmap.org/ui/mapicons/poi_place_city.p.20.png"
    }])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants