leaflet-control-geocoder
leaflet-control-geocoder copied to clipboard
What about `htmlTemplate` option and `html` prop for other geocoders ?
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
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) {