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

[FEATURE] Show results above the search bar #58

Open
dabreegster opened this issue Nov 6, 2024 · 5 comments
Open

[FEATURE] Show results above the search bar #58

dabreegster opened this issue Nov 6, 2024 · 5 comments
Assignees

Comments

@dabreegster
Copy link

Is your feature request related to a problem? Please describe.
I have a map where the top bar can expand or shrink. I've placed the geocoder widget in a fixed position that's usually beneath this bar, but it's quite awkward to use:
image
image

Describe the solution you'd like
I'd like a new option to render the results above the search bar. This would allow a better placement near the bottom of the screen. Skimming through the Svelte compnent, the ul would then appear above <div class="input-group">.

Describe alternatives you've considered
I've also thought about always placing the geocoding control directly beneath my app's top bar, but if it also jumped around as that bar expands/collapses, that might be disorienting.

@zdila
Copy link
Collaborator

zdila commented Nov 15, 2024

I am not sure if I understand you correctly. Do you want an option to display dropdown menu above the search input box? Like this?

image

This should be achievable by adding the following style:

maplibregl-ctrl-geocoder ul {
  top: auto;
  bottom: calc(100% + 6px);
}

@zdila zdila self-assigned this Nov 15, 2024
@petr-hajek
Copy link

petr-hajek commented Dec 6, 2024

@dabreegster Hey, Dustin, thanks for reaching out!
If I understand correctly what you want to achieve, you can actually do it easily by calling
map.addControl(gc, "bottom-right");
It'll then add the control to the bottom corner and have the results displayed above the search box without any extra CSS work.
The code I mentioned will work with MapTiler SDK or Maplibre, it might be slightly different in case you use different library.
Let us know if it solved your issue so we can close this, thanks!

@dabreegster
Copy link
Author

Hi both, thanks for the tips and sorry for the slow response! My current attempt is at https://github.com/acteng/atip/blob/nobuild_geocode_position/src/lib/common/Geocoder.svelte, following https://docs.maptiler.com/svelte/maplibre-gl-js/geocoding-control/.

I can't get the CSS override approach to work with the Svelte component, because nothing with the maplibregl-ctrl-geocoder class name gets created. It's a bit tricky to select the component in Firefox inspector (if you click the results element to focus in inspector, it closes the element), but you can see the class name is autogenerated by Svelte, due to how scoped CSS works:
Screenshot from 2024-12-09 12-46-36

map.addControl(gc, "bottom-right") isn't possible directly through the Svelte layer. I might try dropping down and using https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/maplibre-gl-js/ directly; the Svelte control adds indirection and I'm having some trouble tracing through how some of the config works.

@zdila
Copy link
Collaborator

zdila commented Dec 9, 2024

@dabreegster I see you already use div wrapped which you position with style. You can keep using this approach.

Or you can implement it as in https://github.com/maptiler/maptiler-geocoding-control/blob/main/examples/maptiler-sdk/AppMapTilerSdk.svelte

@petr-hajek Using it as a Svelte component directly in Svelte app may bring some optimizations, but they are negligible.

@petr-hajek
Copy link

@dabreegster never mind my (deleted) comment, only now I had a look at your code

@zdila I believe what we are missing is an easy way how to define position when using createMapLibreGlMapController - something like in https://svelte-maplibre.vercel.app/examples/controls - possibly there will be more people using this library trying to add maptiler-geocoding-control as Svelte component

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

No branches or pull requests

4 participants