-
-
Notifications
You must be signed in to change notification settings - Fork 647
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
GeolocateControl - add option to hide the default button #3103
Comments
Adding this |
Thanks for your response, @HarelM |
You can do it with css, there's no need to add anything to this library... |
Looks like this should work for you to hide the button: .maplibregl-ctrl-geolocate { display: none; } |
Hi this story is still relevant? |
I would love to see this feature implemented, but if not, we can close the story. For now we have copy pasted the code and adapted to our own needs, which works for the moment, but won't be sustainable in the long run. |
I want to take it |
I'm not sure I fully understand the required design here. I would advise to create a design for what is about to be implemented before opening a PR. once this design is approved a PR can be opened with the relevant changes. |
User Story
As a developer, I can hide the default geolocate button that ships with the GeolocateControl, so that I can design and use my own button for this control (and use the
.trigger()
function on the GeolocateControl object to activate the geolocation).Rationale
We provide a custom map for multiple software teams and this map comes with our own, custom styled buttons/controls in the top right corner of the map. We would like to offer the possibility of displaying a GeolocateControl button in our map as well, but currently the default button is hard-coded into the GeolocateControl. If I want the GeolocateControl without the default button, I have to copy paste the entire code file (~700 LOC) plus some additional utility functions from other files, and then remove all HTML and CSS code from within the copied TypeScript file. My proposal is to provide an option to hide this button (see below). The user can then call
geolocateControl.trigger()
to simulate clicking on the default button.Impact
Today, if I want the GeolocateControl without the default button, I have to copy paste the entire code file (~700 LOC) plus some additional utility functions from other files, and then remove all HTML and CSS code from within the copied TypeScript file. With my suggested change, a user could simply set the 'showButton' option to 'false', implement their own button, and when this button is clicked, simply call
geolocateControl.trigger()
on an instance of the officialGeolocateControl
class.Notice the default geolocation button on the top left of this map, and the custom buttons in a different style on the top right of the map:
![image](https://private-user-images.githubusercontent.com/632091/267968160-6d707a49-1a1b-484e-9ba8-47870efdeaa9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg4MDEyMDMsIm5iZiI6MTcxODgwMDkwMywicGF0aCI6Ii82MzIwOTEvMjY3OTY4MTYwLTZkNzA3YTQ5LTFhMWItNDg0ZS05YmE4LTQ3ODcwZWZkZWFhOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxOVQxMjQxNDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xZGEyYWViNjQxMzNjOTQ3MjE3N2E5NzU4MTk3MDM2OGVkY2M5ZjMzOTViMjM0NTVlNzI1MDZiODIwMGZlM2UyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.jBjdq-Scdd4mHIimp29wtnGdZJGCsqp9hiy1F-UEaao)
The text was updated successfully, but these errors were encountered: