I'm creating multipolygon using geojson data. While zooming in/out the precision of the polygon fades, the corner points move.
Any suggestion how i can make the polygon more precise when zoomed out?
This is how my current code looks. I went through the documentation and tried multiple things including smoothFactor, but nothing seems to have a effect.
I'm kinda stuck now and need your help.
var map = L.map('map', {
zoomControl: false,
zoomSnap: 0.0,
scrollWheelZoom: true,
keyboard: false,
dragging: false,
boxZoom: false,
doubleClickZoom: false,
tap: false,
touchZoom: false,
maxNativeZoom: 1,
animate: false,
easeLinearity: 0
});
paths =
[[[[6.858829796182704, 46.95251393022377],
[6.858822143959083, 46.95252165923424],
[6.858803353389316, 46.95251293626237],
[6.858811005614312, 46.952505207253175],
[6.858829796182704, 46.95251393022377]]],
[[[6.858817924471068, 46.95249692043298],
[6.858810272248277, 46.95250464944266],
[6.858791481686369, 46.95249592646894],
[6.858799133910535, 46.95248819746051],
[6.858817924471068, 46.95249692043298]]],
[[[6.858837595845731, 46.95250605229153],
[6.8588299436243805, 46.952513781302564],
[6.858811153056015, 46.95250505833199],
[6.858818805278741, 46.95249732932224],
[6.858837595845731, 46.95250605229153]]]]
geojsonLayer = L.polygon(paths, {
smoothFactor: 0.0,
color: "grey",
weight: 1,
opacity: 1,
fillColor: "white",
fillOpacity: 1,
})
geojsonLayer.addTo(map);
geojsonLayer.smoothFactor = 0.0
console.log(geojsonLayer.getBounds())
map.setZoom(24.851706204825632)
console.log(map.getZoom())
var latlng = L.latLng(6.858817924471068, 46.95249692043298);
map.panTo(latlng)
map.zoomSnap
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 1000px;
width: 1000px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>