Reputation: 3674
My Leaflet Map (Custom one) is relatively small, i made tiles from a 16000x16000 image and implemented them into the website with Leaflet, but the map is too small, the minZoom: 2
is too big and the minZoom 1
is too small.
I would like the Map to fill the whole gray area (which is my map area) but the tiles right now dont fill the whole thing, with bounds i can keep it centered but still not bigger. Any help appreciated.
EDIT 1:
<l-map ref="map" :zoomSnap="zoomSnap" :minZoom="minZoom" :maxZoom="maxZoom" :options="mapOptions" style="background-color: lightgray; width: fill; height: 100%;" :zoom="zoom" :center="center">
<l-tile-layer :options="mapOptions" style="width: 100%; height: 100%" :url="url" :attribution="attribution"></l-tile-layer>
</l-map>
Upvotes: 2
Views: 2344
Reputation: 53360
Use the map zoomSnap
option:
Forces the map's zoom level to always be a multiple of this, particularly right after a
fitBounds()
or a pinch-zoom. By default, the zoom level snaps to the nearest integer; lower values (e.g.0.5
or0.1
) allow for greater granularity. A value of0
means the zoom level will not be snapped after fitBounds or a pinch-zoom.
I suspect you use Vue and Vue2Leaflet plugin.
Your zoomSnap
data should most probably be a member of your mapOptions
data that you pass to the options
prop of the <l-map>
component, instead of being its own prop / attribute.
You would probably also be interested in using the map zoomDelta
option:
Controls how much the map's zoom level will change after a
zoomIn()
,zoomOut()
, pressing+
or-
on the keyboard, or using the zoom controls. Values smaller than1
(e.g.0.5
) allow for greater granularity.
Upvotes: 4