sashuk / watsonc

WatsonC Vidi extension
0 stars 2 forks source link

Multi select of boreholes #44

Closed mapcentia closed 5 years ago

mapcentia commented 5 years ago

Two or more points (boreholes) can be placed very close, making it impossible to select the bottom ones. A way of dealing with this issue is to enable multi-select of boreholes. I've used this hack before to enable multi-select:

var clickBounds = L.latLngBounds(e.latlng, e.latlng), intersectingFeatures = [],
                            res = [156543.033928, 78271.516964, 39135.758482, 19567.879241, 9783.9396205,
                                4891.96981025, 2445.98490513, 1222.99245256, 611.496226281, 305.748113141, 152.87405657,
                                76.4370282852, 38.2185141426, 19.1092570713, 9.55462853565, 4.77731426782, 2.38865713391,
                                1.19432856696, 0.597164283478, 0.298582141739, 0.149291, 0.074645535],
                            distance = 3 * res[cloud.get().getZoom()];

                        for (var l in mapObj._layers) {
                            var overlay = mapObj._layers[l];
                            if (overlay._layers) {
                                for (var f in overlay._layers) {
                                    var feature = overlay._layers[f];
                                    var bounds;
                                    if (feature.getBounds) {
                                        bounds = feature.getBounds();
                                    }
                                    // If point feature
                                    else if (feature._latlng) {
                                        let circle = new L.circle(feature._latlng, {radius: distance});
                                        // DIRTY HACK
                                        circle.addTo(mapObj);
                                        bounds = circle.getBounds();
                                        circle.removeFrom(mapObj);
                                    }
                                    if (bounds && clickBounds.intersects(bounds) && overlay.id) {
                                        intersectingFeatures.push([feature, overlay.id]);
                                    }
                                }
                            }
                        }

If more boreholes are selected, when use tabs: image

sashuk commented 5 years ago

@mapcentia Thank you very much for the snippet!

sashuk commented 5 years ago

@mapcentia Implemented in https://github.com/sashuk/watsonc/commit/084a0d1c614d07d565f5c8e7c16fbc88e90bb0dc

watsonc