Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Polygons at High Zoom Levels #10

Open
Ryllau opened this issue May 31, 2022 · 3 comments
Open

Creating Polygons at High Zoom Levels #10

Ryllau opened this issue May 31, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@Ryllau
Copy link

Ryllau commented May 31, 2022

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

@keul
Copy link
Member

keul commented Jun 1, 2022

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

@Ryllau
Copy link
Author

Ryllau commented Jun 1, 2022

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);

@keul
Copy link
Member

keul commented Jun 14, 2022

@Ryllau I confirm the issue, reproduced.

10-issue

@keul keul added the bug Something isn't working label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants