jedjas12
jedjas12

Reputation: 11

Leaflet Map is Zooming out too far

Using NodeJS to drop datapoints on a map via Leaflet.

Current issue:

When I scroll out, I can't get the map region to be locked to one Earth. That is, when I scroll out all the way, I end up with 5 copies of Earth, unique from each other. I want the map to be locked to one frame of the Earth.

Methods tried:

I've tried using Map.setView, setZoom, fitBounds, setMaxBounds/maxBounds (which was successful in locking panning, but not scrolling). As far as I can tell I've been using these correctly/in the correct places, but still to no avail.

Upvotes: 0

Views: 1276

Answers (1)

jedjas12
jedjas12

Reputation: 11

Figured it out Eugen!

Needs to be set in the initializeLeaflet method. Code added to fix it seen at the bottom of this block.

initializeLeaflet() {
        const mapRoot = this.template.querySelector('.map-root');
        this.map = L.map(mapRoot);
        this.map.fitWorld();
        L.control.scale().addTo(this.map);
        this.map.setMinZoom(2);
        this.map.setMaxZoom(8);
    }

Upvotes: 1

Related Questions