Leaflet.js - following an example - zoom on US

Camillia
Camillia used Ask the Experts™
on
Anyone's used Leaflet.js? I'm following this example https://asmaloney.com/2014/01/code/creating-an-interactive-map-with-leaflet-and-openstreetmap/

You see how the map shows the US and other countries....I want to zoom in on the US when the page loads.

I did this
var maxBounds = [
			[5.499550, -167.276413], //Southwest
			[83.162102, -52.233040]  //Northeast
		];

		var map = L.map( 'map', {
			center: [100.0, 5.0],
			minZoom: 3,
			zoom: 2
		});

		map.setMaxBounds(maxBounds);
		map.fitBounds(maxBounds);

Open in new window


but when the page loads, map still looks small. Looks like this. How can I zoom in on the US when the page loads?
map.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

the minimum zoom is bigger than the default zoom so this is not making sense
The default zoom must be a valid zoom and in the zoom bracket.

Here is an example
zoom: 15, // starting zoom
minZoom: 10,
maxZoom: 18,

Open in new window

that didn't work but I'll play around with it. It made the map very large. I don't see the markers anymore.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial