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

What about htmlTemplate option and html prop for other geocoders ? #357

Open
Cyrille37 opened this issue Dec 25, 2024 · 1 comment
Open

Comments

@Cyrille37
Copy link
Contributor

Cyrille37 commented Dec 25, 2024

Hi

What about htmlTemplate option (and it's associated html) for other geocoders ? It's only available for Nominatim and Photon.

Is there a reason ?
May we suggest Pull request ?

It's very useful for localizing result's items order ;-)

Regards & cheers

@Cyrille37 Cyrille37 changed the title What about htmlTemplate option for other geocoder ? What about htmlTemplate option for other geocoders ? Dec 25, 2024
@Cyrille37 Cyrille37 changed the title What about htmlTemplate option for other geocoders ? What about htmlTemplate option and html prop for other geocoders ? Dec 25, 2024
simon04 added a commit that referenced this issue Dec 26, 2024
@simon04
Copy link
Collaborator

simon04 commented Dec 26, 2024

Hi, I like the idea. I'm happy to review a patch.

I wonder whether there's a good way to achieve this functionality without adapting every single geocoder. Maybe the following?

diff --git a/src/control.ts b/src/control.ts
index ee0fb86..3f3676d 100644
--- a/src/control.ts
+++ b/src/control.ts
@@ -390,6 +390,9 @@ export class GeocoderControl extends EventedControl {
 
     li.setAttribute('data-result-index', String(index));
 
+    if (this.options.htmTemplate) {
+      result.html = this.options.htmTemplate(result);
+    }
     if (result.html) {
       a.innerHTML = a.innerHTML + result.html;
     } else if (text) {

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

2 participants