Code Monkey home page Code Monkey logo

Comments (8)

DrYSG avatar DrYSG commented on July 21, 2024

Looking forward to this.

from leaflet-measure.

brandoncopeland avatar brandoncopeland commented on July 21, 2024

I do like this feature. I know there have been multiple requests, but I don't have a solution that catches all cases well. Any suggestions would be appreciated. Until then, using the start/finish events may be the way to go.

from leaflet-measure.

DrYSG avatar DrYSG commented on July 21, 2024

Well, I don't have a good answer. But I do know that the start/finish is not working well for me. In the example below Car is a L.Marker. (But the truth is that I might have 100+ GeoJson and L.Markers each with a popup box associated with them). But even in the case where I manually do one (the ca). Even trying to turn off the popup, still does not work. Since that area is dead and I cannot put measure control points (they are blocked by the marker from appearing where the CAR is.

So I don't know if making things not clickable is all that needs to be done.

         this.setupMeasure = function () {
             measureControl = new L.Control.Measure({
                 position: 'topleft',
                 primaryLengthUnit: 'meters',
                 secondaryLengthUnit: 'feet',
                 primaryAreaUnit: 'sqmeters',
                 secondaryAreaUnit: 'acres'
             });
             theMap.on('measurestart',
                 function (e) {
                 self.carPopup = Car.theCar.getPopup();
                 Car.theCar.unbindPopup();
                 });
             theMap.on('measurefinish',
             function (e) {
                 Car.theCar.bindPopup(self.carPopup);
             });
         }

from leaflet-measure.

brandoncopeland avatar brandoncopeland commented on July 21, 2024

For your example, I think you will have better luck setting the marker to clickable = false vs unbinding the popup. Unfortunately, the Leaflet API doesn't expose a way to set clickable after the marker has already been created. There is a post on SO describing how this can be done. I haven't tried this, but it does look promising.

If you know all of the map layers in your application and have a reliable way to change their clickable state, I think this is the best solution. But as you mention, this could be an issue if you have too many markers, if you are adding/removing markers during an active measure (after the measure has started), or other cases where it is difficult to maintain what should be clickable what should not be clickable.

from leaflet-measure.

brandoncopeland avatar brandoncopeland commented on July 21, 2024

A couple options..

It would be difficult to disable/enable clicking on other map layers from the control. There are cases where keeping track of this state is complicated. Because there is no method to change clickable on map layers in the Leaflet API, this could lead to other unforeseen issues. This still could be viable, it just needs more investigation.

Another option is to raise the z-index of the _measureDrag marker (or maybe a new transparent marker that also follows the mouse cursor) above all other map layers and handle clicks on this feature instead of the map. This would effectively block out clicks on any existing map layers. This solution would not work on touch devices. This solution is probably more realistic.

from leaflet-measure.

DrYSG avatar DrYSG commented on July 21, 2024

I had seen the "clickable" option, but rejected it since it was a creation option. I tried the SO solution, but I am finding (in Chrome) that it is still a dead space around the Car marker, where one cannot put down measure control points. Raising Z-index is what I would have suggested, and your second option after that also makes sense to me.

from leaflet-measure.

brandoncopeland avatar brandoncopeland commented on July 21, 2024

Ok. Thanks. We're going to try something similar to the second option with an update coming soon.

The plan is to add a marker at the center of the map. The marker will have a transparent DivIcon larger than the screen dimensions of the map, so it will cover the entire visible map. On each map moveend, the marker will reposition itself to the new center. The marker will have a configurable z-index, set relatively high by default, ensuring it is on top of and blocking clicks on all other map layers. click and dblclick on the marker will add measure points just as those events on the map do now.

This is similar to the originally published version of this control. The issues then were 1. we were using a poygon covering the full WGS84 coordinate span (instead of the marker proposed here) and this broke on custom projections and 2. the polygon did not cover existing markers. Neither will be an issue with this plan.

from leaflet-measure.

nguyenning avatar nguyenning commented on July 21, 2024

#46 should solve this issue

from leaflet-measure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.