Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yohann1c
Copy link
Contributor

Hi,

In this fork, I have made some changes for the address search bar. I have used the photon library as a base.
I allow the user to select the service of geocoding. For the moment, the user can select nominatim or the BAN (address database in France) as service. Moreover, I have added the autocompletion by default.
As written on the documentation, I have implemented this in the both (leaflet, openlayers).
I am open for the suggestions to improve and maybe merge this code to the main branch.

Best regards

@andreaordonselli
Copy link
Collaborator

For autocomplete, please read this discussion and let me know your thoughts. If I’m not mistaken, the OSM Foundation prohibits using autocomplete with Nominatim. I look forward to your feedback and thank you for the commit.

@yohann1c
Copy link
Contributor Author

You're right. I quote the Nominatim Usage Policy

Unacceptable Use
The following uses are strictly forbidden and will get you banned:

Auto-complete search This is not yet supported by Nominatim and you must not implement such a service on the client side using the API.
Systematic queries This includes reverse queries in a grid, searching for complete lists of postcodes, towns etc. and downloading all POIs in an area. If you need complete sets of data, get it from the OSM planet or an extract.
Scraping of details The details page is there for debugging only and may not be downloaded automatically.

The fact is I need this version with the BAN for a personal project. I keep this version for my teamwork.
Nevertheless, I think that the search bar will win some improvements if we let the choice for the user to select their provider. Moreover, I have observed some reactions from the search bar with the actual library who are not totally compatible with using a smartphone (same problem in your discussion).
The actual library is efficient because it provide a list of address when we click on enter button or type the enter button. In this way it is appreciable as user and it limits the resources used for the server.
If I success to imitate this functionality, can we commit the pull request? or some developments done or in progress are incompatible?

@yohann1c
Copy link
Contributor Author

I am coming back to you again because I see one think on the leaflet.photon documentation. There is an argument submitDelay. By default, it's set at 300 milliseconds. We can up it to 1000 milliseconds to respect the requirements of the Nominatim Usage Policy of I quote "No heavy uses (an absolute maximum of 1 request per second)".

@andreaordonselli
Copy link
Collaborator

This can solve the situation perfectly, do you have time to prepare a definitive master so I can try it?

@yohann1c
Copy link
Contributor Author

Yes, I don't think it's complicated. Just to change 300 to 1000

@yohann1c
Copy link
Contributor Author

Normally, all is ok. You can try it on your side.

@andreaordonselli
Copy link
Collaborator

I'm sorry, I can't accept the commit; it works quite well with Leaflet, but the graphics don't align with the rest.image

With OpenLayers, it performs much worse; besides not adapting to the graphics, it breaks the functionality of the popup. When clicking on a geometry on the map, the search bar appears instead of the popup. Moreover, it does not adapt in the presence of a title/abstract.
image

It would be necessary to work on fixing their master's program. Regards.

@yohann1c
Copy link
Contributor Author

I have corrected some bugs: the display of the search bar on the left-container and the popup display. Does the display of the labels is normal?

@yohann1c
Copy link
Contributor Author

I will work on the rest the next week

@yohann1c
Copy link
Contributor Author

yohann1c commented Jun 2, 2025

I have made some correction for the display. It's seem correct. I let you try it on your side.

@andreaordonselli
Copy link
Collaborator

  1. The default language of the tool should be English, both in the placeholder and in the search.
  2. Some artifacts still persist, for example, in OpenLayers, if I type something and then delete it, this happens:
    image
  3. In OpenLayers, the icon must appear below the measurement (in the qgis2web.js file, you can find topLeftContainerDiv.appendChild(searchLayerControl); which you can replace with your tool).
  4. In Leaflet, the icon is not centered.
  5. Usability tests have been conducted on smartphones.

I am aware that every update has a significant impact, considering that thousands of users use qgis2web every day.

@yohann1c
Copy link
Contributor Author

yohann1c commented Jun 4, 2025

I have test on firefox and Chrome (with a laptop) and icons seem centered, no artefact(no more scroll bar), english in the placeholder.
For the search results the API is like this https://nominatim.openstreetmap.org/search?format=geojson&addressdetails=1&q={search}&limit=5. By default, nominatim use the HTTP header "Accept-Language" according to documentation. This header is set by the user on his webbrowser. So it's his native language or the language of his country. We can change that thanks to argument accept-language in the URL with value "en" and force the user to have results in english. It can be done quickly.

@andreaordonselli
Copy link
Collaborator

Almost perfect, please:

  • Modify the text in the input to have the first letter capitalized "Nominatim" and "Ban"
  • Fix the alignment of the icon in Leaflet export
    image

I tested the various functionalities of qgis2web, and there don’t seem to be any issues, even from a smartphone.

@yohann1c
Copy link
Contributor Author

BAN stands for (Base Adresse National) so it should be all in capital.
image
I didn't fix the problem of centering the icon because on my web browsers (Firefox and Chrome) it's ok. I even try on Edge. What is your web browser to reproduce this error (Safari maybe)?

@andreaordonselli
Copy link
Collaborator

I'm using your master and export a Leaflet map. I am attaching the export.
qgis2web_2025_06_16-08_53_36_035388.zip

The icon is like this:
image

@yohann1c
Copy link
Contributor Author

I have correct it. I have change the place of the css in the python script. It was in a condition that applied only if the layer list was collapsed. I have also corrected the display of an icon that didn't appear if the search bar address was on "None".

@andreaordonselli andreaordonselli merged commit af6ba66 into qgis2web:master Jul 7, 2025
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

Successfully merging this pull request may close these issues.

2 participants