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

Fix #1 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix #1 #21

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 18, 2019

This pull request is based on the pull request from @Sijmen, and provides an additional fix for the circles that still appear on zoomout.

This works for my current usage, as it assumes the maximum zoom level is 18 and the map is globally available via Window.map, further work may be needed before it can be used as is, but it can be useful for others.

@ghost
Copy link
Author

ghost commented Jan 18, 2019

The important part is the new function "reductor", which adjusts the offset depending on the zoom-level

@trafficonese
Copy link

trafficonese commented Jan 22, 2020

Very nice fix!
Since I am using an R wrapper for this plugin, I wanted to ask if you could modify the reductor function a bit, as otherwise it throws this error in r-leaflet as Window.map is undefined:
Uncaught TypeError: Cannot read property 'getZoom' of undefined

Unfortunately I dont understand why that is the case, but I found a function that would work:

        var reductor = function (dist) {
          var el = $(window.map).data("leafletMap");
          var zoom = el ? el.getZoom() : 18;
          return dist / Math.pow(2, 18 - zoom);
        };

It would probably also be nice to be able to define the exponent (hard coded 2 here). I for example would prefer a value of 1.3. for the current task.

Copy link

@ryankerrad ryankerrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants