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

leaflet-search 2.9.9 not working #265

Closed
benesche1 opened this issue Dec 6, 2020 · 3 comments
Closed

leaflet-search 2.9.9 not working #265

benesche1 opened this issue Dec 6, 2020 · 3 comments

Comments

@benesche1
Copy link

benesche1 commented Dec 6, 2020

Expected Behavior

After typing something in the search box:

  • loader.gif displayed
  • Search "preview" displayed (next best matches)
  • "leaflet-search-jsonp" script tag added

NOTE: This works in my Setup with leaflet-search 2.9.8

Current Behavior

If I type something in the Search Box nothing happens.
When i press enter "Location not found" is displayed

Steps to Reproduce

  1. npm install leaflet-search
  2. my code:

map.addControl( new L.Control.Search({
url: 'https://nominatim.openstreetmap.org/search?format=json&q={s}',
jsonpParam: 'json_callback',
propertyName: 'display_name',
propertyLoc: ['lat','lon'],
marker: L.marker([0,0]),
autoCollapse: true,
autoType: false,
minLength: 2,
}) );

Context (Environment)

I build an nodejs express application. Leaflet-serach is "imported" through require and then everything is translated through browserify.
It worked on my first test 3 weeks ago (version 2.9.8) and now I started over and installed the latest version of leaflet-search (2.9.9). I suspected my code is broken (i switched from no template engine to handlebarsjs) but then I forced installing the previous version and everything worked fine. So I suspect the version is somehow flawed.

Edit: I use leaflet 1.7.1

Detailed Description

Through my debugging process I compared the behavior of version 2.9.9 vs 2.9.8 and I observed that both choose different paths at the first if-statement in the '_fillRecordsCache' function (Line 760). 2.9.9 jumps into the if part an 2.9.8 into the else one


I'm sorry if everything is not that detailed. I'm new to the JavaScript world and don't really know which information is useful. So pls ask if there is anything missing.

@ppete2
Copy link

ppete2 commented Jan 16, 2021

I can confirm this problem. Since some weeks this Leaflet plugin is not working anymore. I used it as Geocoder for Nominatim.

The problem can be reproduced:

In contrast - if you open the same example at Stefano's site https://opengeo.tech/maps/leaflet-search/examples/geocoding-nominatim.html and enter somthing in the search field you'll notice that it works on his site.

@ppete2
Copy link

ppete2 commented Jan 16, 2021

I think I found the reason why the easyblog.it site is working and the github example not. There's 1 code line different:

Within "/src/leaflet-search.js" line 755 has to be changed from
if(this._layer) to if(this.options.layer)

The same should be done within the distribution files "/dist/leaflet-search.min.js" and "/dist/leaflet-search.src.js"

@stefanocudini
Copy link
Owner

stefanocudini commented Aug 18, 2021

solved from version 3.0.0
just published on npm

cheers!

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

No branches or pull requests

3 participants