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

Full width at topright blocks zoom controls #167

Open
timwis opened this issue Oct 14, 2017 · 1 comment
Open

Full width at topright blocks zoom controls #167

timwis opened this issue Oct 14, 2017 · 1 comment

Comments

@timwis
Copy link

timwis commented Oct 14, 2017

Hey folks, great plugin! I'd like to leave the search box open by default as "finding my address" is my primary use case. Setting it to expanded: true works great, but takes up a bit too much real estate on mobile since it's beneath the zoom controls.

screen shot 2017-10-14 at 13 10 39

When I move it to topright it would be great, but then the full width blocks the zoom controls.

screen shot 2017-10-14 at 13 09 29

Any suggestions?

@louh
Copy link
Contributor

louh commented Dec 30, 2017

Hi @timwis,

You'll find your answer here: https://github.com/mapzen/leaflet-geocoder/tree/master/examples#put-the-geocoder-control-above-the-zoom-control

This is a summary (to save you a click). This is an effect of the zoom controls being added by default by Leaflet, so when you add a search bar to the map, it comes "after" the zoom controls.

What you want to do is initialize your map without the zoom controls. Then, add the geocoder, and finally, create a new zoom control and add it afterwards. The code will look like this:

// Initialize a map with zoom control disabled by default
var map = L.map('map', { zoomControl: false });

// Add your geocoder control
L.control.geocoder('<your-api-key>').addTo(map);

// Add zoom control back
L.control.zoom().addTo(map);

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