0

I'm using Leaflet.Measure for measuring areas and distances and I also have several layers on a map. When you click on a layer, the onclick function is being fired and a popup appears. When I start to measure a new area and click on a map layer, the popup appears again and I cannot measure area further. Is there any possibility to mute layer's interactivity, while I'm using measurement tool?

I tired to import my Angular service class into a measuring plugin to change layer's onclick behaviour, but it didn't work. Here's a part of Leaflet.Measure plugin code, which I have modified:

import { MapService} from './app/services/map.service';


L.MeasureAction = L.Handler.extend({

 _onMouseClick: function (event) {
            MapService.enablePopupOpen = false; // if it's set to false, then popup won't open

            //default plugin code
            var latlng = event.latlng || this._map.mouseEventToLatLng(event);
            if (this._lastPoint && latlng.equals(this._lastPoint)) {
                return;
            }
            if (this._trail.points.length > 0) {
                var points = this._trail.points;
                points.push(latlng);
                var length = points.length;
                this._totalDistance += this._getDistance(points[length - 2], points[length - 1]);
                this._addMeasurePoint(latlng);
                //this._addMarker(latlng);
                if (this.options.model !== "area") {
                    this._addLable(latlng, this._getDistanceString(this._totalDistance), "leaflet-measure-lable");
                }
            } else {
                this._totalDistance = 0;
                this._addMeasurePoint(latlng);
                this._addMarker(latlng);
                if (this.options.model !== "area") {
                    this._addLable(latlng, L.Measure.start, "leaflet-measure-lable");
                }
                this._trail.points.push(latlng);
            }
            this._lastPoint = latlng;
            this._startMove = false;
        },

...
})

0 Answers0