leaflet-area-selection icon indicating copy to clipboard operation
leaflet-area-selection copied to clipboard

Creating Polygons at High Zoom Levels

Open Ryllau opened this issue 2 years ago • 3 comments

Sorry for the spam!

I noticed that when zoomed in at level 25+ in leaflet, things get a little weird with the polygons. The click and drag rectangle does not align with the rect-progress-lines and the polygon markers do not create the correction polygon.

zoom level 25 Screen Shot 2022-05-31 at 2 03 46 PM

zoom level 23 Screen Shot 2022-05-31 at 2 04 24 PM

zoom level 20 Screen Shot 2022-05-31 at 2 05 17 PM

Ryllau avatar May 31 '22 18:05 Ryllau

Hi @Ryllau, are you able to provide a codesandbox/codepen example of the issue?

keul avatar Jun 01 '22 10:06 keul

I am not too sure how to use codesandbox/codepen but I referenced your codesandbox and made modifications to the index.js below (if you copy and paste the code below into your codesandbox you should be able to replicate). When you zoom very far in you can begin to see the issues stated above.

My custom tiles that I use for my Leaflet map are rendered at this zoom level which is why I have been running into this issue.

This could also be an underlying issue with Leaflet polygons at this zoom level -- but I am not sure.

Mac OS Monterey v12.3 on Google Chrome v102.0.5

const map = L.map("map").setView([51.505, -0.09], 6);

L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
  attribution:
    '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  maxNativeZoom: 19,
  maxZoom: 30,
  minZoom: 5
}).addTo(map);


const areaSelection = new DrawAreaSelection({
  onPolygonReady: (polygon, control) => {
    let geojsonFg = L.geoJSON(polygon.toGeoJSON(), {
      style: {
        opacity: 0.5,
        fillOpacity: 0.2,
        color: "red"
      }
    });
    geojsonFg.addTo(map);
    control.deactivate();
  },
  onButtonActivate: () => {
    document.getElementById("draw-panel-help").textContent =
      "draw!";
  },
  onButtonDeactivate: () => {}
}).setPosition("topright");

map.addControl(areaSelection);

Ryllau avatar Jun 01 '22 20:06 Ryllau

@Ryllau I confirm the issue, reproduced.

10-issue

keul avatar Jun 14 '22 08:06 keul