You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When line traverse circle in center, what is the closest layer in case of
mouse is over border of circle
line is the first layer in the layers array?
Now line is the closest layer to mouse position. But correct - circle is the closest layer. Need to find closest distance to mouse position using latlng of circle center and it's radius!
maybe edit method closestLayer: function (map, layers, latlng);
like:
closestLayer: function (map, layers, latlng) {
var mindist = Infinity,
result = null,
ll = null,
distance = Infinity;
for (var i = 0, n = layers.length; i < n; i++) {
var layer = layers[i];
// Single dimension, snap on points, else snap on closest
if (typeof layer.getLatLng == 'function') {
ll = layer.getLatLng();
distance = L.GeometryUtil.distance(map, latlng, ll);
if (layer instanceof L.Circle){
distance = distance - layer.getRadius();
}
}
else {
ll = L.GeometryUtil.closest(map, layer, latlng);
if (ll) distance = ll.distance; // Can return null if layer has no points.
}
if (distance < mindist) {
mindist = distance;
result = {layer: layer, latlng: ll, distance: distance};
}
}
return result;
}
The text was updated successfully, but these errors were encountered:
When line traverse circle in center, what is the closest layer in case of
Now line is the closest layer to mouse position. But correct - circle is the closest layer. Need to find closest distance to mouse position using latlng of circle center and it's radius!
maybe edit method closestLayer: function (map, layers, latlng);
like:
The text was updated successfully, but these errors were encountered: