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

<Question> Change zoom level #680

Open
Chiller999 opened this issue Nov 6, 2022 · 4 comments
Open

<Question> Change zoom level #680

Chiller999 opened this issue Nov 6, 2022 · 4 comments

Comments

@Chiller999
Copy link

Hi there,
I didn't find some option to customize the zoom level.

I don't wanne use manual zooming&centering. I would like to use the fitSelectedRoutes true defaults but zooming out one step.
Background: I am using custom markers and they are cutting of :(

Thanks for any help or suggestions.

@Chiller999 Chiller999 changed the title Change zoom level <Question> Change zoom level Nov 6, 2022
@curtisy1
Copy link
Collaborator

curtisy1 commented Nov 7, 2022

Leaflet maps offer a zoomOut or setZoom function which you could use.

Suppose you have a simple map, you could do something like this

const map = new L.Map(); // your init logic goes here
const currentZoom = map.getZoom();
map.setZoom(currentZoom - 1);

@Chiller999
Copy link
Author

Thanks for this suggestion! It is only working after L.Routing.control(...).addTo(map); is finished.
So I put zoomOut inside a setTimeout. But is there any better option? For example like ...addTo(map).finished(zoomOut())?

@curtisy1
Copy link
Collaborator

curtisy1 commented Nov 7, 2022

Leaflet maps fire a load event which tells you when the map is ready.

map.on('load', () => {
    map.setZoom(map.getZoom() - 1);
});

@Chiller999
Copy link
Author

Thanks, that's what I was searching for. But sad, that it is not possible to modify the fitting directly.

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