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

Marker Opacity not changing #26

Open
danyhiol opened this issue Jul 27, 2018 · 1 comment
Open

Marker Opacity not changing #26

danyhiol opened this issue Jul 27, 2018 · 1 comment

Comments

@danyhiol
Copy link

I found out that the markers opacities never changes.
While debugging your code, I realized that mapPixelBounds.y and mapPixelBounds.x both return undefined, leading to markerDistance to become NaN because of L.bounds() returning object with min and max.
Here is a working code:

// bottom out
            if (y < center.y ){
              y = mapPixelBounds.min.y + markerHeight/2;
              x = center.x -  (center.y-y) / Math.tan(Math.abs(rad));
              markerDistance = -currentMarkerPosition.y - mapPixelBounds.max.y;
            // top out
            }else{
              y = mapPixelBounds.max.y - markerHeight/2;
              x = center.x - (y-center.y)/ Math.tan(Math.abs(rad));
              markerDistance = - mapPixelBounds.max.y + currentMarkerPosition.y ; 
            }
          }else {

            // left out
            if (x < center.x ){
              x = mapPixelBounds.min.x + markerWidth/2;
              y = center.y -  (center.x-x ) *Math.tan(rad);
              markerDistance = -currentMarkerPosition.x;
            // right out
            }else{
              x = mapPixelBounds.max.x - markerWidth/2;
              y = center.y +  (x - center.x) *Math.tan(rad);
              markerDistance = currentMarkerPosition.x - mapPixelBounds.max.x;
            }
          }
@ubergesundheit
Copy link
Owner

Thanks! I would appreciate if you would create a pull request with the required files changed.

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

No branches or pull requests

2 participants