Leaflet.EdgeMarker
Leaflet.EdgeMarker copied to clipboard
Marker Opacity not changing
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;
}
}
Thanks! I would appreciate if you would create a pull request with the required files changed.